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* *i*^2 ≤ *n*:
*if* *A*[*i*] is *true*:
*for* *j* = *i*^2, *i*^2 + *i*, *i*^2 + 2*i*, ..., *while* *j* ≤ *n*:
*A*[*j*] = *false*
Now all *i* such that *A*[*i*] is *true* are prime.
I'm having a problem creating the data structure A.
What I want to do is create a map of integers from 2 to n all initialized to
true that I can then prune using the algorithm.
Any ideas?
Thank you,
Kevin
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en