Skip to content

Instantly share code, notes, and snippets.

@mmis1000
Created April 27, 2018 11:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmis1000/951107b88f77eee3128ab7659ed1b23c to your computer and use it in GitHub Desktop.
Save mmis1000/951107b88f77eee3128ab7659ed1b23c to your computer and use it in GitHub Desktop.
var a;
var max = 10;
console.log('start')
for (a = 0; a < max; a++) {
console.log(a)
}
console.log('exit')
//
const recurr = (fn => fn(
(f => f(f))
(self =>
x =>
fn(self(self))(x)
)
))
recurr(
main=>
actions=>
branch=>
x=>
max=>
actions[branch](main)(actions)(x)(max)
)
({
0:
main=>
actions=>
x=>
max=>(
console.log('start'),
main(actions)(1)(0)(max)
),
1:
main=>
actions=>
x=>
max=>(
x < max ?
main(actions)(2)(x)(max):
main(actions)(4)(x)(max)
),
2:
main=>
actions=>
x=>
max=>(
console.log(x),
main(actions)(3)(x)(max)
),
3:
main=>
actions=>
x=>
max=>(
main(actions)(1)(x + 1)(max)
),
4:
main=>
actions=>
x=>
max=>(
console.log('exit')
),
})
(0)
(null)
(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment