On 15.12.2008, at 02:24, Mark H. wrote: >> (lazy-cons X1 (lazy-cons X2 (transform-to-gaussian uniform- >> rest)))))) > > Also much better -- the structs were ugly. Thanks for the nice > revision!
In fact, this is a good test-case for the interface design for random- number generators. If you want to be able to implement rejection- based ones (which are numerous), there is a lot to gain from an interface in terms of lazy sequences. The Box-Muller transform is even more difficult because it transforms pairs of numbers. With any other interface that would require some bookkeeping for managing the additional state (first/second member of the pair), whereas a sequence-based interface makes it nearly trivial. Long live laziness! ;-) > Do you think type hints on the double-floats could give some > performance benefit? I'm curious where the type hints would go but > too lazy to try the "add them everywhere and remove one by one until > performance decreases" approach. I have no experience at all with type hints. For example, I wonder if Clojure already uses the calls to Math.log etc. to determine that certain numbers must be floats. It would be nice to have tools that show what type information the compiler already knows. Konrad. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---