On Mon, Sep 26, 2011 at 1:21 AM, Dennis Haupt <[email protected]> wrote:
> (let [rand (new java.util.Random) nextInt (fn [a] (.nextInt rand))]
> ((map (print) (iterate ((nextInt "dummy") 0)))))
>
>
> the error is:
> java.lang.ClassCastException: java.lang.Integer cannot be cast to
> clojure.lang.IFn (NO_SOURCE_FILE:0)
>
> why does it want to cast my "0" to a function? and how can i get rid
> of the dummy parameter [a]?
You have too many parentheses in your code. The error is coming
because of the ``((nextInt "dummy") 0)'' line where you are trying to
call an integer (the result of calling nextInt on "dummy") as a
function.
I don't know what exactly you are trying to achieve here, but assuming
that you want n consecutive pseudo-random integers, I would write it
like this -
(let [rnd (java.util.Random.)
next-int #(.nextInt rnd)]
(repeatedly 10 next-int)) ; substitute 10 with desired number
Regards,
BG
--
Baishampayan Ghose
b.ghose at gmail.com
--
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