[CM] random stream with lists?

Orm Finnendahl finnendahl@folkwang-hochschule.de
Wed, 24 Sep 2003 16:37:42 +0200


Am 24. September 2003, 08:25 Uhr (-0500) schrieb Rick Taube:
> 
> I included the :weight options in the example above so that you can see 
> the format of the specification. But of course ':weight 1' is also the 
> default value so you dont need to include these BUT you still need to 
> use the "long specification" form.  The end result is that it looks 
> like each element is double list:
> 
> (new random :of '(
>                   ((2 1 3) )
>                   ((2) )
>                   ((3 1) )
>                   ((1 2) )
>                   )
>               :for 3)

Thanks again. I suspected something like that but wasn't smart enough
to find it in the dictionary (I didn't even find it now grepping "long
specification" in the dictionary html sources). 

I wrote a little wrapper to avoid the typing of the extra brackets in
the default (:weight 1) case. I put it below in case someone is
interested in rather trivial code. It's scheme. IIRC the lisp defmacro
needs another bracket around the first 'args.

(defmacro d-list args
  `(loop
    for elem in ',args
    collect (list elem)))

(new random :of (d-list (2 1 3) (2) (3 1) (1 2)) :for 3)

--
Orm