Group Abstract Group Abstract

Message Boards Message Boards

9
|
12.2K Views
|
2 Replies
|
19 Total Likes
View groups...
Share
Share this post:

How lack of iterators limits the usefulness of combinatorial enumeration

Posted 7 years ago
POSTED BY: Szabolcs Horvát
2 Replies

I agree with this—obviously. Also the concept of yield in Pythons is quite nice actually.

To alleviate some of the problems with Tuples and Subsets I created SelectTuples and SelectSubsets: https://resources.wolframcloud.com/FunctionRepository/resources/SelectTuples and https://resources.wolframcloud.com/FunctionRepository/resources/SelectSubsets which might help you in some cases.

Both do not create all of the tuples/subsets at once but rather one-by-one, so the memory footprint is tiny.

EDIT: SelectPermutations is still in development, will come soon…

POSTED BY: Sander Huisman

I completely agree with this. Personally, I think that something along the lines of Haskell-style lazy lists fits best with WL's paradigms. In the past I did an exercise to try an implement this from scratch, though I'm aware that similar functionalities are already hidden in the language. The advantage of lazy lists is that you can capture the stateful part of the iteration in the held tail of the list explicitly. So you can have a function that extracts a few elements from the lazy list and then also returns the tail to allow further extraction of elements.

POSTED BY: Sjoerd Smit
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard