This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-27
Channels
- # announcements (1)
- # aws (17)
- # babashka (2)
- # beginners (14)
- # calva (1)
- # cider (16)
- # clara (1)
- # clj-kondo (68)
- # cljdoc (2)
- # clojure (51)
- # clojure-dev (1)
- # clojure-italy (2)
- # clojure-spec (1)
- # clojure-uk (19)
- # clojurescript (34)
- # cursive (4)
- # fulcro (1)
- # heroku (3)
- # leiningen (36)
- # lumo (28)
- # music (2)
- # off-topic (16)
- # reagent (22)
- # specter (7)
- # sql (7)
Hi everyone! I'm trying to wrap my head around zippers, and it appears that a node can either have 1) a value or 2) children. Therefore this throws an error:
(-> (z/vector-zip [1 2 3])
(z/down)
(z/insert-child [7 8 9])
)
Is there a way to have a node a value AND children? (Maybe some other type of tree structure?)I figured it out - instead of using vector-zip I create a custom zipper
@vachichng yeah, pretty much. Throw some code in a future, store the value returned by the call to future, then dereference it once you need the value.
So something like acct-balance
for the name, and @acct-balance
when I want to get the value out.
yeah I mean, do you give it a prefix or something when declaring the binding ? like (def acct-balance (future (get-balance "asd"))
in that case, later in the function I could forget to deref acct-balance and trigger bugs
It wouldn’t be in a def, since that would be top level. Instead, it’d be in a let binding inside a function.