coll is the vector defined at the top of each code listing in the examples given, and is used as the second argument to map in all examples.
Sent from my iPhone On Jun 28, 2011, at 3:20 PM, octopusgrabbus <octopusgrab...@gmail.com> wrote: > Thanks. I've followed most of what you've written except how the > symbol col fits into this, unless you're using it as map values. > > On Jun 28, 3:11 pm, Mark Rathwell <mark.rathw...@gmail.com> wrote: >> map takes a function and a collection. So, that function can be: >> >> 1. named: >> - define the function on it own, using the defn macro >> - pass it as first argument to map >> >> (def coll [[1 2] [3 4] [4 5]]) >> >> (defn foo [x y] >> (println x y)) >> >> (map foo coll) >> >> 2. anonymous: >> - use shorthand notation #(...) >> -- for one argument function, % represents the argument >> -- for multiple args, use %1, %2, %3, etc., which represent arg in >> specified position >> - use the fn special form (fn [x y] ...) >> - specify these inline in map call >> >> (def coll [[1 2] [3 4] [4 5]]) >> >> (map #(println %1 %2) coll) >> >> (map (fn [x y] (println x y)) coll) >> >> On Tue, Jun 28, 2011 at 2:58 PM, octopusgrabbus >> <octopusgrab...@gmail.com>wrote: >> >> >> >> >> >> >> >>> Given this sample: >> >>> (ns test-csv >>> (:gen-class) >>> (:use clojure.contrib.command-line) >>> (:use clojure-csv.core)) >> >>> (defn x1 >>> [val1 val2] >>> (println val1 val2)) >> >>> (defn process-file >>> "Process csv file and prints a column in every row" >>> [file-name] >>> (let [data (slurp file-name) >>> rows (parse-csv data)] >>> (dorun (map #(println ( nth % 11 nil)) rows)))) >> >>> (defn -main [& args] >>> (with-command-line args >>> "Get csv file name" >>> [[file-name ".csv file name" "resultset.csv"]] >>> [[file-name ".csv file name" 1]] >>> (println "file-name:", file-name) >>> (process-file file-name))) >> >>> I would like to print out two or more values, or creating a vector of >>> those values would be helpful. I have been experimenting, but either >>> get errors or nothing printed out. >> >>> I am just not sure how to approach this. >>> Thanks. >>> cmn >> >>> -- >>> 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 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 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