jsonpiler 0.11.0

a Json syntax programming language for Windows
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This program computes fib(10) * 2 = 110.
define(fib_recursive, { n: Int }, Int,
  { if(n <= 1, ret(n)); fib_recursive(n - 1) + fib_recursive(n - 2) }
)
define(fib_loop, { n: Int }, Int,
{
  if(n <= 1, ret(n))
  let(a) = 0
  let(b) = 1
  let(i) = 2
  while(i <= n, { let(t) = a + b; a = b; b = t; i += 1 })
  b
}
)
assert(fib_recursive(10) == fib_loop(10) == 55, "fib error")
export(fib_recursive, fib_loop)
fib_recursive(10)