-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

i wasn't really trying to achieve anything useful - just messing
around and see where i get.

now i'm here:
(defrecord point [x y z])
(defn genPoints [n]
  (let [random (new Random)
        randomInt #(.nextInt random)
        randomPoint #(new point (randomInt) (randomInt) (randomInt))]
    (repeatedly n randomPoint)))

is there a way to avoid writing (randomInt)(randomInt)(randomInt) and
instead something like (magic (repeatedly 3 randomInt))?

Am 25.09.2011 22:14, schrieb Baishampayan Ghose:
> On Mon, Sep 26, 2011 at 1:21 AM, Dennis Haupt
> <d.haup...@googlemail.com> 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
> 


- -- 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOgO+8AAoJENRtux+h35aGF2kP/3MGVpxqqkax5O0kmX/Kh9u5
b48b6YrlgPwbSvTra2aqs+4rLF4U8mUUN82XyacB+PFAc6PeE3I8/aJudUvFO0RP
c8qL31NKPSm8RTvhPWzBejh2pyu1cP4qZtmgrSFfSan34n/oadfi0w8c1AjHsQqr
MVMMo2gY/U4J68wG2I7bNdbx3VT1OtmZlY04UBh5D9F6NXJ11+hEZLS89K32F6up
hi0EoruOxgeJnWDMLdTsKCUiSzlI8m6ZSlRVu8aj/xkdfcDXQhNVLp/UEmKhX355
wdkZm7VHHKop1c057vlXO8Fz6eUZ2E1RV3jf2osieg3Exj5s4cHncUES5cxZ14NF
6b0Avqxf69yX5ids2OOTaTqWrniRVqhf2KyDZGmgJfgwDyfLxMeephp/3glfYrbf
L3CIsXmjwebtFkwDm9LJvO8DXsOY+NU2ZgwfGCRqbwNxQU+0TMsGGgIypvD2rnM1
zAQE9kmcKLALLOwFcu6hN/OntpjtOk5e51hA7V/1oAk8H0BWOEKW1aYMggwoySgG
ti9BPg8MqyTBtZmqFUyOPFH3EQr8sEjRXpu2Wf1RxATShfNWwalqeOHbEhV/vJkO
SunWpUn/eqKaTzAq+ZI9VrWteMrmklHDlo7PhEwkp6JVFxUj3psfkQeqdY9fSRjz
Ei2jqCQXBMRO2CGEC/+R
=bKcz
-----END PGP SIGNATURE-----

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to