Re: Newbie: Creating a MapEntry

2008-11-21 Thread Stephen C. Gilardi
On Nov 21, 2008, at 10:23 AM, J. McConnell wrote: > user=> (defn map-entry [k v] (first {k v})) Very nice! --Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send emai

Re: Newbie: Creating a MapEntry

2008-11-21 Thread Rich Hickey
On Nov 21, 11:40 am, samppi <[EMAIL PROTECTED]> wrote: > Yes, thank you—(key) and (val) were what I was interested in, so I'll > use the latter function you gave. What I'm wondering though is, if > MapEntries aren't guaranteed for the future, what is being planned for > (key) and (val) too. Oh,

Re: Newbie: Creating a MapEntry

2008-11-21 Thread samppi
Yes, thank you—(key) and (val) were what I was interested in, so I'll use the latter function you gave. What I'm wondering though is, if MapEntries aren't guaranteed for the future, what is being planned for (key) and (val) too. Oh, well. :) On Nov 21, 8:23 am, "J. McConnell" <[EMAIL PROTECTED]>

Re: Newbie: Creating a MapEntry

2008-11-21 Thread J. McConnell
On Fri, Nov 21, 2008 at 12:03 AM, samppi <[EMAIL PROTECTED]> wrote: > > Is it possible to create a MapEntry from scratch? The reason why I'm > asking is because I want to mess with sequences of two-sized vectors, > and it would be really cool if I could use the key and val functions > on them rath

Re: Newbie: Creating a MapEntry

2008-11-21 Thread Rich Hickey
On Nov 21, 12:07 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: > On Nov 21, 2008, at 12:03 AM, samppi wrote: > > > Is it possible to create a MapEntry from scratch? > > user=> (def a (clojure.lang.MapEntry. 3 4)) > #'user/a > user=> (key a) > 3 > user=> (val a) > 4 > user=> > > You can als

Re: Newbie: Creating a MapEntry

2008-11-20 Thread wlr
On Nov 21, 12:03 am, samppi <[EMAIL PROTECTED]> wrote: > I want to mess with sequences of two-sized vectors, Maybe destructuring will do: user> (dorun (map (fn [[k v]] (println "Key " k "Value " v)) [ [:a 3] [:b 2] [:a 1] [:c 0]])) => Key :a Value 3 Key :b Value 2 Key :a Value 1 Key :c Val

Re: Newbie: Creating a MapEntry

2008-11-20 Thread samppi
Thank you very much. On Nov 20, 10:07 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: > On Nov 21, 2008, at 12:03 AM, samppi wrote: > > > Is it possible to create a MapEntry from scratch? > > user=> (def a (clojure.lang.MapEntry. 3 4)) > #'user/a > user=> (key a) > 3 > user=> (val a) > 4 > us

Re: Newbie: Creating a MapEntry

2008-11-20 Thread Stephen C. Gilardi
On Nov 21, 2008, at 12:03 AM, samppi wrote: > Is it possible to create a MapEntry from scratch? user=> (def a (clojure.lang.MapEntry. 3 4)) #'user/a user=> (key a) 3 user=> (val a) 4 user=> You can also make it a little shorter by importing clojure.lang.MapEntry . --Steve --~--~-~-

Newbie: Creating a MapEntry

2008-11-20 Thread samppi
Is it possible to create a MapEntry from scratch? The reason why I'm asking is because I want to mess with sequences of two-sized vectors, and it would be really cool if I could use the key and val functions on them rather than (get % 0) and (get % 1): (map #(str "Key:" (key %) "Value:" (val %)