Created
November 6, 2021 23:18
-
-
Save artur-s/83f18e63f7b588a220d6e011f69af0d0 to your computer and use it in GitHub Desktop.
`scanLeft` in terms of `fold` and `map`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let scanLeft (s:'s) (f:'s -> 'a -> 's) (lst:'a list) : 's list = | |
lst | |
|> List.mapi (fun i _ -> | |
lst | |
|> List.take i | |
|> List.fold f s ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment