Thanks, 

Still not what I was expecting.

Suppose I have a map called records which has this [{:name ‘roelof’ :city 
‘secret’} {:name ‘somewhere-else’ :city ‘who-knows’}]

When I do : 

(defn convert-back
    "converts the map back to a csv string"
      [{:keys [name, glitter-index]}, records ]
      (map (fn [{:keys [name glitter-index]}] (clojure.string/join "," 
[name glitter-index]))) records)     

I see this error message : 

ArityException Wrong number of args (1) passed to: core/convert-back  
clojure.lang.AFn.throwArity (AFn.java:429)

and when im doing : 

(defn convert-back
    "converts the map back to a csv string"
      [records ]
      (map (fn [{:keys [name glitter-index]}] (clojure.string/join "," 
[name glitter-index]))) records)  

I see this as output ; 

{:name "roelof", :glitter-index 2}

Frustating to learn clojure 



Op vrijdag 23 oktober 2015 14:50:30 UTC+2 schreef Colin Yates:

> clojure.string/join not clojure.join/string
>
> On 23 Oct 2015, at 13:49, r/ Wobben <wobb...@gmail.com <javascript:>> 
> wrote:
>
> Thanks, 
>
> I tried it like this : 
>
> (defn convert-back
>     "converts the map back to a csv string"
>       [{:keys [name, city]}, records ]
>       (map (fn [{:keys [name city]}] (clojure.join/string “,” [name 
> city]))) records)  
>
> and then I do : (convert-back {:name "roelof" :city: secret}, { :name "X" 
> :city "Earth"} )
>
> and I see this error when running in repl : 
>
> #error {
>  :cause clojure.join
>  :via
>  [{:type clojure.lang.Compiler$CompilerException
>    :message java.lang.ClassNotFoundException: clojure.join, 
> compiling:(chapter_4/core.clj:56:47)
>    :at [clojure.lang.Compiler analyzeSeq Compiler.java 6730]}
>   {:type java.lang.ClassNotFoundException
>    :message clojure.join
>    :at [java.net.URLClassLoader$1 run URLClassLoader.java 366]}]
>  :trace
>  [[java.net.URLClassLoader$1 run URLClassLoader.java 366]
>   [java.net.URLClassLoader$1 run URLClassLoader.java 355]
>   [java.security.AccessController doPrivileged AccessController.java -2]
>
> e clojure.join
>  :via
>  [{:type clojure.lang.Compiler$CompilerException
>    :message java.lang.ClassNotFoundException: clojure.join, 
> compiling:(chapter_4/core.clj:56:47)
>    :at [clojure.lang.Compiler analyzeSeq Compiler.java 6730]}
>   {:type java.lang.ClassNotFoundException
>    :message clojure.join
>    :at [java.net.URLClassLoader$1 run URLClassLoader.java 366]}]
>  :trace
>  [[java.net.URLClassLoader$1 run URLClassLoader.java 366]
>   [java.net.URLClassLoader$1 run URLClassLoader.java 355]
>   [java.security.AccessController doPrivileged AccessController.java -2]
>
>
> #error {
>  :cause clojure.join
>  :via
>  [{:type clojure.lang.Compiler$CompilerException
>    :message java.lang.ClassNotFoundException: clojure.join, 
> compiling:(chapter_4/core.clj:56:47)
>    :at [clojure.lang.Compiler analyzeSeq Compiler.java 6730]}
>   {:type java.lang.ClassNotFoundException
>    :message clojure.join
>    :at [java.net.URLClassLoader$1 run URLClassLoader.java 366]}]
>  :trace
>  [[java.net.URLClassLoader$1 run URLClassLoader.java 366]
>   [java.net.URLClassLoader$1 run URLClassLoader.java 355]
>   [java.security.AccessController doPrivileged AccessController.java -2]
>
> Roelof
>
>
> (convert-back  {:name "roelof" :glitter-index 2 })(convert-back  {:name 
> "roelof" :glitter-index 2 })
>
>
> Op vrijdag 23 oktober 2015 14:25:44 UTC+2 schreef Colin Yates:
>>
>> (apply clojure.string/join “," (vals my-map)) would work but you can’t 
>> guarantee the order.
>>
>> (map (fn [{:keys [name city]}] (clojure.join/string “,” [name city]))) 
>> my-map) gives you control of the order in which the fields are processed.
>>
>> You could also look at juxt as well?
>>
>> On 23 Oct 2015, at 12:49, r/ Wobben <wobb...@gmail.com> wrote:
>>
>> Hello, 
>>
>> As a challenge I need to convert a map structure to a csv structure. 
>>
>> So ( { :name "roelof", :city secret }) need to be converted to roelof, 
>> secret. 
>>
>> I think I can use something like (map clojure.string/join  ..) for it but 
>> it seems I have to make a function out of the :name roelof part to get 
>> roelof back. 
>>
>> I could use  get for then I do not know how to call 1 records of the 
>> whole map. 
>>
>> Can someone explain in simple English how I can solve this one ? 
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com <javascript:>
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com <javascript:>
> 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+u...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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.

Reply via email to