Hello, I am new to fucntional programming and have 2 questions:
How can I apply a function to each element from a list and a second
parameter?
(def lstr '("Hello1" "Hello2" "Hello3"))
(defn addtoString [s1 s2]
(str s1 s2))
(apply (addtoString lstr "World"))
---------
I need it for the following example (pseudo code).
How would you realize this in Clojure?:
function testit [times, function, list, s]
for (0 to times)
def start = System.nanoTime()
def results = []
for (i = 0 to list.length())
results.add(function(listelement(i), s))
def end = System.nanoTime()
println "run took " end-start " ns"
println "results are: "
results.each { result => println result }
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en