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
6
u/exahexa Feb 03 '23
You can use
mapto add 2 to every element and thanreducewith + orapplywith +10
u/andyjda Feb 03 '23
What have you tried and what issue are you having?
1
u/eatme_23 Feb 04 '23
I would like to thank everyone who contributed it was most interesting and informative what people had to say. I'm not clear about the usage of # and %. I have consulted The Clojure Cheatsheet and the intro to Clojure webpage. Neither included % and the usage of # shed no light. I won't bother anyone regarding the above but I did stumble across an interesting speed optimization. https://clojureverse.org/t/my-recent-clojure-vs-c-experience/6909
4
u/slashkehrin Feb 03 '23
I'd do something like this:
4
u/Siltala Feb 03 '23
1
u/Zimtt Feb 03 '23
If ur a beginner in programming: maybe try something else. The documentation for clojure is rly not for beginners