(map m [:a :b]) is a nice trick, we use it a lot in cascalog queries:
(map ?account [:id :updated-at :created-at] :> ?id ?updated-at ?created-at)

Where juxt would require more ceremony because of the need for 
serialization ((mapfn [m] ((juxt :id :updated-at :created-at) m)) ?account 
:> ?id ?updated-at ?created-at)

On Friday, October 23, 2015 at 7:42:24 AM UTC-7, Colin Yates wrote:
>
> Kicking myself I didn’t grok (map m [:a :b])!
>
> On 23 Oct 2015, at 15:32, Aaron Cohen <aa...@assonance.org <javascript:>> 
> wrote:
>
> I think you might find the following blog post helpful: 
> http://blog.jayfields.com/2011/01/clojure-select-keys-select-values-and.html
>
> What you are asking for is basically (clojure.string/join (select-values 
> my-map vals)) where select-values is defined in several ways in the linked 
> blog post.
>
> For code golf points, the briefest example from the blog that would work 
> for your purposes might be:
>
> (defn select-values [m ks] (map m ks))
>
> So:
>
> user=> (def my-map { :name "roelof", :city "big-secret" })
>
> user=> (clojure.string/join ", " (map my-map [:name :city]))
> "roelof, big-secret"
>
>
> On Fri, Oct 23, 2015 at 7:49 AM, r/ Wobben <wobb...@gmail.com 
> <javascript:>> 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 
>> <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 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