diff --git a/examples/factorial.bc b/examples/factorial.bc new file mode 100644 index 0000000..409094a --- /dev/null +++ b/examples/factorial.bc @@ -0,0 +1,2 @@ +define f(x) {if(x <= 1){1}else{f(x - 1) * x}} +f(100) diff --git a/examples/higherorder.bc b/examples/higherorder.bc new file mode 100644 index 0000000..53cdab2 --- /dev/null +++ b/examples/higherorder.bc @@ -0,0 +1,3 @@ +define inc(x) { x + 1} +define call(f, arg) { f(arg)} +call(inc, 10) diff --git a/examples/phi.bc b/examples/phi.bc new file mode 100644 index 0000000..9b263d3 --- /dev/null +++ b/examples/phi.bc @@ -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) diff --git a/src/BC/Parse.hs b/src/BC/Parse.hs index 36e6d06..56835da 100644 --- a/src/BC/Parse.hs +++ b/src/BC/Parse.hs @@ -88,7 +88,6 @@ headAndBlock parser = do _ <- P.string ")" _ <- optspace body <- block - _ <- optspace return (args, body)