4 ms·
> If your loop isn't a map, it's almost certainly a fold. ...all loops can be represented as folds
by calpaterson 13y ago
> If your loop isn't a map, it's almost certainly a fold.
...all loops can be represented as folds
- tel 13y agoNot strictly true, but all maps can be represented as a fold. That's not usually the best tool though.
- tel 13y agoTo clarify this now that I'm not on my phone, folds may not express termination by themselves, they depend upon the type that they're folding up. More formally, folds are catamorphisms which operate on data, but you often need to use codata to generate the structures to fold over.