Update trampoline docs to new interface.
This commit is contained in:
parent
b47166144d
commit
df135b8c9b
1 changed files with 3 additions and 3 deletions
|
@ -19,9 +19,9 @@ main = asText <| fac 1000000000000
|
||||||
Trampolining allows for long-running tail-recursive loops to be run without pushing calls onto the stack:
|
Trampolining allows for long-running tail-recursive loops to be run without pushing calls onto the stack:
|
||||||
```haskell
|
```haskell
|
||||||
facT : Int -> Int -> Trampoline Int
|
facT : Int -> Int -> Trampoline Int
|
||||||
facT n acc = Trampoline <| if n <= 0
|
facT n acc = if n <= 0
|
||||||
then Left acc
|
then Done acc
|
||||||
else Right <| \() -> facT (n - 1) (n * acc)
|
else Continue <| \() -> facT (n - 1) (n * acc)
|
||||||
fac : Int -> Int
|
fac : Int -> Int
|
||||||
fac n = trampoline <| facT n 0
|
fac n = trampoline <| facT n 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue