Created
November 10, 2023 16:49
-
-
Save cowlike/9758eae1f7c3f8425bab917dcb52cf92 to your computer and use it in GitHub Desktop.
continuation-based recursion
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 rec reduce' (f: 'a -> 'a -> 'a) init xs cont = | |
match xs with | |
| [] -> cont init | |
| x :: xs -> reduce' f init xs (fun y' -> cont <| f x y') | |
reduce' (+) 0 [1..5] id | |
reduce' (+) 0UL [1UL..1000000UL] id | |
reduce' (+) 0UL [1UL..999999UL] id | |
reduce' (+) 0UL [1UL..100_000_000UL] id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment