Awesome. It amazes me what Clojure can do. Thanks for everyone's help.
On Nov 15, 6:56 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Nov 15, 12:09 am, "Brian Doyle" <[EMAIL PROTECTED]> wrote:
>
> > Another way to create a map is:
>
> > user=> (apply hash-map [:a 1 :b 2 :c 3])
> > {:a 1, :c 3, :
On Nov 15, 12:09 am, "Brian Doyle" <[EMAIL PROTECTED]> wrote:
> Another way to create a map is:
>
> user=> (apply hash-map [:a 1 :b 2 :c 3])
> {:a 1, :c 3, :b 2}
>
Yes, that's fine, and for the flatten:
(interleave (keys m) (vals m))
Rich
> On Fri, Nov 14, 2008 at 9:42 PM, samppi <[EMAIL PR
user=> (mapcat identity {:a 1 :b 2 :c 3})
(:c 3 :b 2 :a 1)
On Sat, Nov 15, 2008 at 4:05 AM, Kevin Downey <[EMAIL PROTECTED]> wrote:
> user=> (reduce concat {:a 1 :b 2 :c 3})
> (:c 3 :b 2 :a 1)
> user=>
>
>
> On Sat, Nov 15, 2008 at 4:02 AM, Matthias Benkard <[EMAIL PROTECTED]> wrote:
>>
>> On 1
On 15 Nov., 05:17, samppi <[EMAIL PROTECTED]> wrote:
> Fold isn't build into Clojure
Isn't fold just clojure/reduce?
Matthias
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, s
user=> (reduce concat {:a 1 :b 2 :c 3})
(:c 3 :b 2 :a 1)
user=>
On Sat, Nov 15, 2008 at 4:02 AM, Matthias Benkard <[EMAIL PROTECTED]> wrote:
>
> On 15 Nov., 05:17, samppi <[EMAIL PROTECTED]> wrote:
>> Fold isn't build into Clojure
>
> Isn't fold just clojure/reduce?
>
> Matthias
> >
>
--
The
Another way to create a map is:
user=> (apply hash-map [:a 1 :b 2 :c 3])
{:a 1, :c 3, :b 2}
On Fri, Nov 14, 2008 at 9:42 PM, samppi <[EMAIL PROTECTED]> wrote:
>
> Excellent! I must remember about the apply function. Thank you very
> much.
>
> On Nov 14, 9:35 pm, "Kevin Downey" <[EMAIL PROTECTED
On Fri, Nov 14, 2008 at 8:33 PM, Kevin Downey <[EMAIL PROTECTED]> wrote:
> On Fri, Nov 14, 2008 at 8:17 PM, samppi <[EMAIL PROTECTED]> wrote:
>>
>> Yeah, I need to be able to do this to easily manage trees of maps. I
>> meant, how would you idiomatically implement their algorithms?
>>
>> Fold isn'
Excellent! I must remember about the apply function. Thank you very
much.
On Nov 14, 9:35 pm, "Kevin Downey" <[EMAIL PROTECTED]> wrote:
> On Fri, Nov 14, 2008 at 8:33 PM, Kevin Downey <[EMAIL PROTECTED]> wrote:
> > On Fri, Nov 14, 2008 at 8:17 PM, samppi <[EMAIL PROTECTED]> wrote:
>
> >> Yeah, I
On Fri, Nov 14, 2008 at 8:17 PM, samppi <[EMAIL PROTECTED]> wrote:
>
> Yeah, I need to be able to do this to easily manage trees of maps. I
> meant, how would you idiomatically implement their algorithms?
>
> Fold isn't build into Clojure, but they should still somehow be
> possible...right?
>
> O
Yeah, I need to be able to do this to easily manage trees of maps. I
meant, how would you idiomatically implement their algorithms?
Fold isn't build into Clojure, but they should still somehow be
possible...right?
On Nov 14, 9:12 pm, Michel Salim <[EMAIL PROTECTED]> wrote:
> On Nov 14, 10:56 pm,
On Nov 14, 10:56 pm, samppi <[EMAIL PROTECTED]> wrote:
> I'm trying to figure out how to do this:
>
> (flat-map-seq {:a 3, :b 1, :c 2}) ; returns (:a 3 :b 1 :c 2)
>
(defn flat-map-seq [m]
(if (empty? m) '()
(let [kv (first m)]
(lazy-cons (kv 0) (lazy-cons (kv 1) (flat-map-seq (rest
I'm trying to figure out how to do this:
(flat-map-seq {:a 3, :b 1, :c 2}) ; returns (:a 3 :b 1 :c 2)
...and vice versa:
(map-from-flat-collection {} [:a 3 :b 1 :c 2]) ; returns {:a 3, :b
1, :c 2}
Anyone have any idiomatic ideas?
--~--~-~--~~~---~--~~
You r
12 matches
Mail list logo