I'm used to Python's itertools for doing functional things with iterators (F#: sequences) and wondered if there were equivalents in F# or a commonly used library since they're so handy.
The top tools for me are:
- product : cartesian product, equivalent to a nested for-loop
- combinations
- permutations
- takewhile
- dropwhile
- chain : chain multiple iterators together into a new longer iterator
- repeat* : repeat(5) -> 5, 5, 5...
- count* : count(10) -> 10, 11, 12...
- cycle* : cycle([1,2,3]) -> 1,2,3,1,2...
* I suppose these 3 would yield monads in F#? How do you make them infinite?
I'm prompted to ask because I saw this question on permutations in F# and was surprised it was not part of a library or built into the language.
TakeWhile,dropwhilechaining and repeating are all included in the default F# libs. - John Palmer