4 ms·
[see above]
by jewbacca 14y ago
[see above]
- masklinn 14y agoOh, didn't know about `replicateM_`. Not sure I like it much though, seems... redundant.
- jewbacca 14y agoIt's a pretty common pattern, I think it's worth its own word, at least as much as mapM: mapM f xs = sequence (map f xs) replicateM n x = sequence (replicate n x) Another cool thing replicateM is equivalent to: for lists, it's the cartesian power (sequence is the cartesian product). ...this is actually the primary reason I'm aware of it.