lisp.js | A Lisp-Interpreter JavaScript - designed to be | Interpreter library
kandi X-RAY | lisp.js Summary
kandi X-RAY | lisp.js Summary
Basically you don't need a webserver to run lisp.js. The tests (contained in the tests folder) will also work locally on your machine. But using jsconsole and webworkers it is impossible, due to security reasons, that your browser will run lisp.js correctly. So there are two ways to try lisp.js.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of lisp.js
lisp.js Key Features
lisp.js Examples and Code Snippets
Community Discussions
Trending Discussions on lisp.js
QUESTION
I am trying to implement a small subset of the programming language LISP, using JavaScript as source language. When the this small lisp is fed the a string looking like this:
...ANSWER
Answered 2017-Dec-12 at 21:13This is because there is a tiny bug in your code.
When you call the evaluate(lambdaBody, lambdaEnvironment)
at line:134, you provide lambdaBody
as the first argument, which is the expr
argument in the 'function evaluate(expr, env)' function (line:138). During your evaluation you consume it with tempArg = expr.shift();
function and get out of the loop when its empty. For the second time, your lambdaBody
is unfortunately an empty array.
To fix it, you should change the evaluate function not to modify its arguments (e.g. create a copy and consume the copy)
I suggest you fix the bug in the evaluate function, but a sample that really works is to change line 134 to deep copy lambdaBody
as below:
QUESTION
So I am trying to implement a subset of LISP using JavaScript. I am stuck on two things related to lambdas.
How to implement the ability to create a lambda and at the same time feed it the arguments and have it immediately evaluated? For example:
...ANSWER
Answered 2017-Dec-27 at 14:25You don't inspect the structure of the operand to see if it's a lambda
you eval
the operand. The standard way of eval
is to check if it's primitive type, then check for special forms and macros, then eval the operator and operands before applying.
Just remove the part where expr[0][0] === 'lambda' || expr[0][0] === 'string'
is true and instead of just returning the evaluation of the form you need to apply
the operand:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lisp.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page