This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-28
Channels
- # admin-announcements (59)
- # aws (27)
- # beginners (42)
- # boot (22)
- # cider (5)
- # clojure (97)
- # clojure-australia (3)
- # clojure-italy (2)
- # clojure-japan (9)
- # clojure-russia (81)
- # clojure-sg (2)
- # clojurescript (86)
- # clojutre (1)
- # cloxp (2)
- # cursive (60)
- # datomic (24)
- # docs (1)
- # editors (1)
- # emacs (17)
- # hoplon (57)
- # instaparse (1)
- # jobs (11)
- # ldnclj (19)
- # re-frame (1)
- # reagent (3)
- # spacemacs (7)
- # testing (8)
- # yada (127)
trying to reason about a way to improve it based on my limited clj knowledge but having no luck
@samueldev: You have a specific question?
so I want default-vegetables
to be a vector, each element therein being the result of calling schema/map->AddVegetable on a different vegetable
->AddVegetable
and map->AddVegetable
are functions that are created automatically when you create AddVegetable
records.
Wait, sorry, you wanted something more like (map (partial ->AddVegetable vegetable-id) [(->SquashInfo) (->GreenAppleInfo) …])
So, AddVegetable
is the record. Clojure automatically makes map->AddVegetable
and ->AddVegetable
functions for you. You can also instantiate the class directly with (AddVegetable.)
, but that’s generally discouraged.
What’s the best way to convert a sequence/collection into a list? This is the only way I know which seems guaranteed to work:
(->> my-seq-or-coll
(into (list))
(into (list)))
Also, why would you need to do that?
Hi all! I'm making queries via clojure.jdbc, and when I've printed response I see that all hashes are converted in to #object[java.util.HashMap 0x3bc3ff69 {93=37, 91=38, 99=65, 89=44}
But, if I make request instantly in repl I get correct response without converting
{"93" "37", "91" "38", "99" "65", "89" "44"}
What is the problem here?
Looks like that there is difference between println displaying and if we directly select symbol with reponse inside
@djanus: with list
you are creating a new list with each of the items included. So for example, doing (list '(1 2 3))
would eval to ((1 2 3))
, a 1-item list of a seq. apply
essentially reduces your collection into a series of arguments -- you are basically making it into (list 1 2 3)
which would eval to (1 2 3)
. Though after playing around a bit you can create a PersistentList using seq
on a seq or coll. It's kind of what list*
does (http://conj.io/store/v1/org.clojure/clojure/1.7.0/clj/clojure.core/list*)
@djanus: Because I was playing with writing an interpreter in the browser: http://www.lispcast.com/the-most-important-idea-in-computer-science ... and I wanted to ensure I’m maintaining a list. But maybe that’s silly of me, dunno. I could treat seqs like lists.