To add a little, into is generic and has no special treatment if the
collection is a map, but works with maps if the elements are vectors
because map associations of key-value pairs are a subclass of vector. The
other way around:
user= (for [elem {:foo :bar}] elem)
([:foo :bar]) ; extracts :foo
Hi all,
I was wondering why this doesn't create a map 1 - 2 :
(into {} (partition 2 2 12))
Must be yet another misunderstanding of mine.
Thanks
Andy
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
For reasons unclear to me, (into {} ...) expects a sequence of 2-element
*vectors*, not just 2-element collections. partition returns a seq of lists,
not vectors, which is why you're getting that exception. You could try (into {}
(map vec (partition 2 2 12))) instead.
On Mar 26, 2014, at 15:36
into expects that because it is implemented with conj.
(conj {} [:foo :bar])
{:foo :bar}
On Wednesday, March 26, 2014 4:41:16 PM UTC-4, Michael Gardner wrote:
For reasons unclear to me, (into {} ...) expects a sequence of 2-element
*vectors*, not just 2-element collections. partition
Thanks Justin, this is a terrific implementation.
--
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
Thanks Sumil.
Does anyone know what algorithm they are implementing? It looks like a wheel
factorization but I can't tell from lack ofcomments.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
See also David Nolan's post:
http://dosync.posterous.com/lispers-know-the-value-of-everything-and-the
Justin
On Tuesday, August 9, 2011 6:02:00 PM UTC-4, pmbauer wrote:
For the sieve, if performance matters, clojure's native data structures may
not be the best choice.
A mutable array of
Hi,
I have a question regarding the map data structure. I'm trying to program a
Sieve of Eratosthenes using the algorithm at Wikipedia:
*Input*: an integer *n* 1
Let *A* be an array of bool values, indexed by integers 2 to *n*,
initially all set to *true*.
*for* *i* = 2, 3, 4, ..., *while*
user= (def n 5)
#'user/n
user= (zipmap (range 2 (inc n)) (repeat true))
{5 true, 4 true, 3 true, 2 true}
user=
As a start...
On Aug 9, 10:50 am, Kevin Sookocheff kevin.sookoch...@gmail.com
wrote:
Hi,
I have a question regarding the map data structure. I'm trying to program a
Sieve of
(zipmap (range 2 (inc n)) (repeat true))
--
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
For the sieve, if performance matters, clojure's native data structures may
not be the best choice.
A mutable array of boolean primitives could be more apropos.
(defn prime-sieve [^long n]
(let [^booleans sieve (make-array Boolean/TYPE (inc n))]
...)
... using aset/aget to write/read
you should considering looking at clojure.contrib.lazy-seqs/primes to get an
idea it is implemented there..
Sunil.
On Wed, Aug 10, 2011 at 1:48 AM, Chouser chou...@gmail.com wrote:
On Tue, Aug 9, 2011 at 12:50 PM, Kevin Sookocheff
kevin.sookoch...@gmail.com wrote:
Hi,
I have a question
12 matches
Mail list logo