Skip to content

Instantly share code, notes, and snippets.

@artur-s
Created November 6, 2021 23:18
Show Gist options
  • Save artur-s/83f18e63f7b588a220d6e011f69af0d0 to your computer and use it in GitHub Desktop.
Save artur-s/83f18e63f7b588a220d6e011f69af0d0 to your computer and use it in GitHub Desktop.
`scanLeft` in terms of `fold` and `map`
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