I have the following function:
(defn lucky-numbers
"Lucky numbers from 1 up-to upto-value.
1 <= upto-value <= 10.000.000
http://en.wikipedia.org/wiki/Lucky_number"
; doc-string and pre-condition should match
[upto]
{:pre [(>= upto 1)
(<= upto (* 10 1000 1000))]}
(if (< upto 3)
; for 1 and 2 the algorithm does not work, so return value
manually
(list 1)
(loop [coll (range 1 (inc upto) 2), survivor-idx 1]
(let [i (nth coll survivor-idx)]
(if (> (count coll) i)
(recur (drop-every-nth coll i) (inc survivor-idx))
coll)))))
In this function I limit the maximum value that can be given to the
function. But this is pure for performance reasons. So I would like to have
the possibility to disable it. I read somewhere that you can use types for
this. Sadly I do not remember where.
At the moment the following:
(lucky-numbers 10000001)
gives:
AssertionError Assert failed: (<= upto (* 10 1000 1000))
user/lucky-numbers
But I would like the following to be executed:
(lucky-numbers :no-max-check 10000001)
How would I implement that?
--
Cecil Westerhof
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.