parser: maybe fixed a parser bug; examples: added them
This commit is contained in:
2
examples/factorial.bc
Normal file
2
examples/factorial.bc
Normal file
@@ -0,0 +1,2 @@
|
||||
define f(x) {if(x <= 1){1}else{f(x - 1) * x}}
|
||||
f(100)
|
3
examples/higherorder.bc
Normal file
3
examples/higherorder.bc
Normal file
@@ -0,0 +1,3 @@
|
||||
define inc(x) { x + 1}
|
||||
define call(f, arg) { f(arg)}
|
||||
call(inc, 10)
|
10
examples/phi.bc
Normal file
10
examples/phi.bc
Normal file
@@ -0,0 +1,10 @@
|
||||
define phi(x) {
|
||||
t = 0
|
||||
s = x
|
||||
b = x
|
||||
q = x * x
|
||||
i = 1
|
||||
while (s != t) {s = (t = s) + (b = b * (q / (i = i + 2)))}
|
||||
const = 0.5 * l(8 * a(1))
|
||||
0.5 + s * e(-0.5 * q - const)}
|
||||
phi(1)
|
@@ -88,7 +88,6 @@ headAndBlock parser = do
|
||||
_ <- P.string ")"
|
||||
_ <- optspace
|
||||
body <- block
|
||||
_ <- optspace
|
||||
return (args, body)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user