[racket] partitions
Hi Phil, Deren and Jensaxel,
Thanks for your quick responses.
To Phil:
I have read your code, but it is not lazy.
I think that for large n memory is going to be a problem.
Your eager approach resembles much my lazy code, but I produce the
partitions in reverse order.
Thanks anyway.
To Deeren
I'll send you the code privately.
As an example of the ordering:
(stream->list (make-partitions-stream 5)) ->
_____
From: Deren Dohoda [mailto:deren.dohoda at gmail.com]
Sent: martes, 06 de mayo de 2014 20:36
To: Jos Koot
Cc: Racket mailing list
Subject: Re: [racket] partitions
Hi Jos,
Actually I'd love to have you share it. I did write myself a partition
generator but it was eager and I never went back to make it into a sequence
or stream, though I'm sure it was somewhere in my to-do list. How are they
ordered?
Deren
On Tue, May 6, 2014 at 2:26 PM, Jos Koot <jos.koot at gmail.com> wrote:
Hi
Library *math/number-theory* provides procedure *partitions*,
which fastly tells you how many partitions a given nonnegative integer has
(based on http://en.wikipedia.org/wiki/Partition_(number_theory))
I have not found any procedure that generates the partitions themselves,
nor in PLT Racket nor in Planet.
Therefore I made my own code for procedures that
produce (lazy) streams and sequences of partitions
(make-partition-stream n) and (in-partitions n).
If you are interested, let me know and I'll send you the code.
It is too long to include it in this mail
(77 lines of docs, 31 lines of code and 160 lines of tests)
I would be happy with some feedback on my code.
Or even happier with a pointer to already existing code.
Best whishes, Jos
____________________
Racket Users list:
http://lists.racket-lang.org/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140506/963e6ec4/attachment-0001.html>