parser: maybe fixed a parser bug; examples: added them

This commit is contained in:
2017-05-25 18:04:57 -04:00
parent e91588ab96
commit e612b3c226
4 changed files with 15 additions and 1 deletions

2
examples/factorial.bc Normal file
View 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
View 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
View 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)

View File

@@ -88,7 +88,6 @@ headAndBlock parser = do
_ <- P.string ")"
_ <- optspace
body <- block
_ <- optspace
return (args, body)