Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type SmartList<'State, 't> = ('State -> 't -> 'State) -> 'State -> 'State
- let fromList L folder state = Seq.fold folder state L
- let fold folder state L = L folder state
- let map f L folder state = L (fun s el -> folder s (f el)) state
- let filter p L folder state =
- let updatedFolder s el =
- if p el then folder s el
- else s
- L updatedFolder state
- // check
- let result = fromList [1; 2; 3; 4; 5] |> filter (fun x -> x > 2) |> fold (+) 0
- printfn "%A" result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement