On Jan 5, 2016 7:49 AM, "gvim" <gvi...@gmail.com> wrote: > > On 05/01/2016 13:44, Josh Kamau wrote: >> >> Here is an extremely simple example: >> >> Problem: add a list of numbers >> >> java: You put something like this in a class in a method >> >> int[] numbers = {1,2,3,4,5,6,7,7,8,4,3} ; >> >> int sum = 0 ; >> for(int i = 0; i < sum.length; i++) { >> sum = sum + i; >> } >> >> return sum; >> >> >> clojure: You put this in a clojure namespace >> >> (def numbers [1 2 3 4 54 56 6]) >> >> ;;to get the sum >> (reduce + numbers) >> >> >> You get the idea ;) >> >> Josh >> >> > > Or simply: > > (reduce + [1 2 3 4 54 56 6]) > Or (+ 1 2 3 4 54 56 6)
-- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.