H
Hendrik Maryns
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
Hi,
as some of you might have read, I have this little method which computes
the cartesian product of a set up to a certain number. Now, of course,
this gets rather memory intensive, and I can?t get past about 20^5. So,
I will have to use a trick to build the cartesian product, use its
values, and discard them again while I am still building it.
I see two options:
- Not build the whole CP first, but rather build it incrementally.
- Give the ?stuff? to be done to the function building the CP.
Once again, I see a Lisp construct which sort of does the last, with
mapcan and mapcar like stuff, which gets a function as argument, to be
executed on each value of a list.
In Java, this is a candidate for the Strategy pattern: make a class
which does the stuff, and give it as a parameter to the function that
builds the CP.
Other option: have a separate class that builds the CP and have it
return the values incrementally. This sounds like an Iterator: it keeps
track of information, and gives the next() if it is asked for it.
Which of these both approaches is best for this problem? Does anybody
see (dis)advantages to one of those approaches?
The Iterator approach fits better into the code I already have, but it
is not too late yet to rewrite parts of it.
Thanks for some thoughts, H.
--
Hendrik Maryns
==================
www.lieverleven.be
http://aouw.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFEBtWje+7xMGD3itQRAoqKAJ4gSNt8pP8SrGEWeznvgzARMSR9+wCfXPc6
KGYeHPWPFp+dauwiFBI6Ixk=
=mbJ3
-----END PGP SIGNATURE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
Hi,
as some of you might have read, I have this little method which computes
the cartesian product of a set up to a certain number. Now, of course,
this gets rather memory intensive, and I can?t get past about 20^5. So,
I will have to use a trick to build the cartesian product, use its
values, and discard them again while I am still building it.
I see two options:
- Not build the whole CP first, but rather build it incrementally.
- Give the ?stuff? to be done to the function building the CP.
Once again, I see a Lisp construct which sort of does the last, with
mapcan and mapcar like stuff, which gets a function as argument, to be
executed on each value of a list.
In Java, this is a candidate for the Strategy pattern: make a class
which does the stuff, and give it as a parameter to the function that
builds the CP.
Other option: have a separate class that builds the CP and have it
return the values incrementally. This sounds like an Iterator: it keeps
track of information, and gives the next() if it is asked for it.
Which of these both approaches is best for this problem? Does anybody
see (dis)advantages to one of those approaches?
The Iterator approach fits better into the code I already have, but it
is not too late yet to rewrite parts of it.
Thanks for some thoughts, H.
--
Hendrik Maryns
==================
www.lieverleven.be
http://aouw.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFEBtWje+7xMGD3itQRAoqKAJ4gSNt8pP8SrGEWeznvgzARMSR9+wCfXPc6
KGYeHPWPFp+dauwiFBI6Ixk=
=mbJ3
-----END PGP SIGNATURE-----