[parenscript-devel] random, mapcar, and loop

Vladimir Sedach vsedach at gmail.com
Wed May 19 17:39:50 UTC 2010


Hi Yong,

I've pushed your first two patches. As for random - you're right,
calling floor on everything is not the right thing to do. OTOH I think
it's the most used pattern. It's easy enough to write (* number
(random)) when you really need a random floating point number.

Vladimir

2010/5/11 szergling <senatorzergling at gmail.com>:
> I have three patches to suggest for parenscript. Two seem relatively
> minor to me, but a third modifies random to be more like CL:RANDOM. It
> gives us the following:
>
> CL-USER> (ps:ps (random 2.3))
> "2.3 * Math.random();"
> CL-USER> (ps:ps (random 2))
> "Math.floor(2 * Math.random());"  ;; as in ps's original random
>
> But I expect the following to be perhaps a bit more contentious...
>
> CL-USER> (ps:ps (random (+ 2 2)))
> "var max1 = 2 + 2;
> var val2 = max1 * Math.random();
> if (Math.floor(max1) === max1) {
>    Math.floor(val2);
> } else {
>    val2;
> };"
>
> Hope I haven't tried too hard to be like CL here? I hope my patches are
> useful and would like them to be considered for inclusion.
>
> Thanks,
>
> Yong.
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>
>




More information about the parenscript-devel mailing list