This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-12
Channels
- # aleph (22)
- # aws (7)
- # babashka (17)
- # beginners (69)
- # chlorine-clover (9)
- # cider (2)
- # clj-kondo (3)
- # cljdoc (30)
- # clojure (113)
- # clojure-dev (30)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (16)
- # clojure-spec (1)
- # clojure-sweden (3)
- # clojure-uk (17)
- # clojurescript (77)
- # cryogen (12)
- # data-science (5)
- # datomic (27)
- # duct (2)
- # emacs (37)
- # fulcro (24)
- # graphql (2)
- # kaocha (1)
- # lambdaisland (27)
- # leiningen (4)
- # off-topic (15)
- # onyx (1)
- # other-lisps (3)
- # re-frame (94)
- # reagent (2)
- # reitit (20)
- # ring (1)
- # shadow-cljs (66)
- # spacemacs (5)
- # sql (59)
- # tools-deps (140)
- # vim (1)
- # xtdb (17)
I'm trying to learn Common Lisp and I'm stuck on something.
(map 'list '+ (mapcar
(lambda (s)
(sums-of-children ht s))
children))
That doesn't work because the syntax needs to be (map <type> <fn> a b c rest...)
and I'm giving it (map <type> <fn> (list of a b c rest...)
I can't figure out how to re-write it in a way that works. I'm experimenting with backquoting and using unquote-splice, but that seems way too contrived to be correct.For context, this is inside a recursive function, sums-of-children
, which returns a list of (<int> <int>)
if it's a leaf and the sum of it's children (`(<sum of children car> <sum of children cadr)`) if it's not a leaf.
Ah hah. A misunderstanding of apply
. Simple. Just put apply
at the beginning of that first form I'm using. https://stackoverflow.com/questions/2627262/how-do-i-splice-into-a-list-outside-of-a-macro-in-common-lisp