Commit 64baa609 authored by Phuntsok Drak-pa's avatar Phuntsok Drak-pa

added PRAKDA source file example for Fibonacci

parent a7393cec
$$$
Declaration of the function `fib` which takes either a function returning a
literal int or a literal int itself as its argument, and returns a literal int
$$$
make fib: $ declaration of the `fib` function
(i: () -> int) $ takes a function returning an int with no
$ argument as argument
-> int $ returns a literal int
<- begin $ beginnig of block of instruction
make a: $ function `a`
(i: () -> int) $ taking an function without argument returning
$ a literal int as its argument
-> int $ returns a literal int
<- fib(i - 1); $ its body is a call to fib
make b: $ same for function `b`
(i: () -> int)
-> int
<- fib(i - 2);
make res: $ function `res`
(a: (int) -> int), $ takes a function taking an `int` as its
$ argument, can be a literal or a returned value
$ and returns a literal int
(b: (int) -> int), $ same
(i: () -> int) $ function returning a literal int without
$ argument
-> int $ returns a literar int
<- a(i) + b(i); $ body, calls `a` and `b` with their argument `i`
<- res(&a, &b, &i); $ returns evaluation of `res`
end; $ end of block of instruction for `fib`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment