This:

randomPoint #(apply new point (repeatedly 3 randomInt))

does not work, but is almost what you want.  It doesn't work because new is
a macro, and apply only works with functions as the first arg.

Using the following two lines, first to define a function, then to use it
with apply, seems like it ought to work.  Not sure whether it is magic
enough for you, though :-)

newpt #(new point %1 %2 %3)
randomPoint #(apply newpt (repeatedly 3 randomInt))

Andy


On Mon, Sep 26, 2011 at 3:49 PM, Jeremy Heiler <jeremyhei...@gmail.com>wrote:

> On Mon, Sep 26, 2011 at 5:33 PM, Dennis Haupt <d.haup...@googlemail.com>
> wrote:
> > 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))?
>
> I'm not sure if this the best way, but it would work.
>
> (eval `(new point ~@(take 3 (repeatedly #(rand-int 10)))))
>
> --
> 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
>

-- 
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