Skip to content

Instantly share code, notes, and snippets.

@menduz

menduz/do-while.dwl

Created Nov 17, 2017
Embed
What would you like to do?
Do while
%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
You can’t perform that action at this time.