1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

factorial example, bring back println for now

This commit is contained in:
azur 2023-03-07 04:41:34 +07:00
parent 50fdc4fe97
commit e6b31b39b0
2 changed files with 14 additions and 0 deletions

8
example/fact.hlm Normal file
View file

@ -0,0 +1,8 @@
func fact (n : num) num =
if n == 0 then
1
else
n * fact(n - 1)
;
println(fact(5));

View file

@ -154,6 +154,12 @@ pub fn translate_js_expr(expr: Expr) -> JSExpr {
match *f {
Expr::Sym(ref s) => {
match s.as_str() {
"println" => JSExpr::Call(
Box::new(JSExpr::Method(
Box::new(JSExpr::Sym("console".to_string())),
"log".to_string(),
)),
args.into_iter().map(translate_js_expr).collect()),
"print" => JSExpr::Call(
Box::new(JSExpr::Method(
Box::new(JSExpr::Method(