Skip to content

Instantly share code, notes, and snippets.

@menduz
Created November 17, 2017 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menduz/27835dde5eddd1078f41026ffcd4953d to your computer and use it in GitHub Desktop.
Save menduz/27835dde5eddd1078f41026ffcd4953d to your computer and use it in GitHub Desktop.
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