[CM] random stream with lists?
Johannes Quint
johannes.quint@web.de
Wed, 24 Sep 2003 14:47:04 +0200
On Dienstag, September 23, 2003, at 02:43 Uhr, Orm Finnendahl wrote:
> Hi,
>
> does anybody know of a straightforward way to do random streams with
> lists as elements in cm 2.4?
>
> This obviously doesn't work, but shows what I mean:
>
> (new random :of '((2 1 3) (2) (3 1) (1 2)) :for 3)
>
> -> ((2 1 3) (1 2) (2 1 3))
>
> I'd prefer not to use a random stream of numbers to reference the
> elements outside of the stream.
not so elegant, but it works:
(setf x
(new random :of
(list (new chord :of '(2 1 3))
(new chord :of '(2))
(new chord :of '(3 1))
(new chord :of '(1 2))
)))
(next x 3)
=>
((2 1 3)(1 2)(2 1 3))
j.