other-lisps

Eric Ihli 2020-02-12T16:27:17.001600Z

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.

Eric Ihli 2020-02-12T16:28:47.002900Z

For context, this is inside a recursive function, sums-of-children , which returns a list of (&lt;int&gt; &lt;int&gt;) 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.

Eric Ihli 2020-02-12T16:58:56.003700Z

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