Created
November 17, 2017 21:08
-
-
Save menduz/27835dde5eddd1078f41026ffcd4953d to your computer and use it in GitHub Desktop.
Do while
This file contains 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
%dw 2.0 | |
output application/json | |
fun while<T>(a, b: (T) -> Boolean) = do { | |
var r = a() | |
fun innerWhile(x) = do { | |
var r = a(x) | |
--- | |
b(r) match { | |
case true -> [r ~ innerWhile(r)] | |
case false -> [r] | |
} | |
} | |
--- | |
[r ~ innerWhile(r)] | |
} | |
--- | |
do { | |
(x = 0) -> x + 1 | |
} while ($ < 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment