Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let rollupResult s =
- let rec traverse acc current =
- match current with
- | Ok x :: xs->
- traverse (x :: acc) xs
- | Error x :: _ -> Error x
- //because we build the list backwards, reverse at the end to preserve input order.
- | [] -> acc |> List.rev |> Ok
- traverse [] s
- let testData = [|
- Ok 1
- Ok 2
- //uncomment to see error returned.
- //Error "incorrect"
- Ok 3
- |]
- Array.toList testData
- |> rollupResult
- |> printfn "%A"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement