[Fluxus] picking a function with weights

Kassen signal.automatique at gmail.com
Tue Feb 2 06:08:07 PST 2010


Dear list,

Another -probably simple- Scheme question. Suppose we wanted to execute one
(and only one) of a few functions, pick this one randomly and assign weights
to them. For example we might like to populate a world with mostly cubes,
some spheres and just a few cylinders. How would we go about this cleanly? I
could nest a train of "if" statements that would compare a (rndf) to a
constant but that's hardly convenient and leads to ugly code. I could also
set up a few (cond) statements to use with a single random number but since
we are basically dealing with picking from a list I could imagine Scheme,
which is specialised in lists, would have some specialised trick up it's
sleeve that might serve?

Yours,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pawfal.org/pipermail/fluxus-pawfal.org/attachments/20100202/f6901de9/attachment-0002.htm>


More information about the Fluxus mailing list