From f62ff280441201e722c99eb4cfbfe553694ad5cf Mon Sep 17 00:00:00 2001 From: "Tomoya Matsuura(MacBookPro)" Date: Sat, 25 Nov 2023 02:58:50 +0900 Subject: [PATCH] update --- content/Node.jsで約100行で書くLISP風ラムダ計算.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/content/Node.jsで約100行で書くLISP風ラムダ計算.md b/content/Node.jsで約100行で書くLISP風ラムダ計算.md index 7e34b7ad..23bc9bcb 100644 --- a/content/Node.jsで約100行で書くLISP風ラムダ計算.md +++ b/content/Node.jsで約100行で書くLISP風ラムダ計算.md @@ -17,7 +17,6 @@ const reader = require("readline").createInterface({ const tokenize = (str) => str.match(/[\(]|[\)]|[\+\-\*\/]|[a-zA-Z_]+|(-?\d+(\.\d+)?)/g); - const parse_token = (token, stack, res) => { switch (token) { case '(': { @@ -40,7 +39,6 @@ const parse_token = (token, stack, res) => { } } } - const parse = (tokens) => { let stack = []; let next_res = []; @@ -52,7 +50,6 @@ const parse = (tokens) => { const read = (str) => parse(tokenize(str)); const binop = (args, fn) => fn(args[0], args[1]); - const env = { "parent": null, "+": args => binop(args, (a, b) => a + b), @@ -100,7 +97,7 @@ const eval = (expr, env) => { return fn(expr.map(e => eval(e, env))) } } else { - return fn + return null } } }