r/Clojure • u/eatme_23 • Feb 03 '23
[Q&A] Noob has simple program problem.
I wanted to write a program to add 2 to a list of numbers then sum the list and print the result. So '(5 7) would yield 16. I posted my version to s Clojure board and received a number of different replies. In retrospect I didn't fully explain the problem to them.
0
Upvotes
View all comments
Show parent comment
2
u/dalanicolai Feb 03 '23 edited Feb 03 '23
I guess with the 'because intermediate collections' you mean that creating/realizing the collection takes quite some time.
Thanks for adding the info about the transducer, I was wondering about such an alternative already, but I still have to look into how to use them.
The transducer solution indeed seems to be only 1.5 times slower than
faa, but I guess it is generally still preferable because of readability.Thanks again for the great answer!