lisp | Toy Lisp 15 interpreter | Interpreter library
kandi X-RAY | lisp Summary
kandi X-RAY | lisp Summary
To install: go get robpike.io/lisp. This is an implementation of the language defined, with sublime concision, in the first few pages of the LISP 1.5 Programmer's Manual by McCarthy, Abrahams, Edwards, Hart, and Levin, from MIT in 1962. It is a pedagogical experiment to see just how well the interpreter (actually EVALQUOTE/APPLY) defined on page 13 of that book really works. The answer is: perfectly, of course. This program was a joy to put together. Its purpose was fun and education, and in no way to create a modern or even realistic Lisp implementation. The goal was to turn that marvelous page 13 into a working interpreter using clean, direct Go code.
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
lisp Key Features
lisp Examples and Code Snippets
Community Discussions
Trending Discussions on lisp
QUESTION
I have been trying to learn about functional programming, but I still struggle with thinking like a functional programmer. One such hangup is how one would implement index-heavy operations which rely strongly on loops/order-of-execution.
For example, consider the following Java code:
...ANSWER
Answered 2022-Mar-07 at 21:17This is not an index-heavy operation, in fact you can do this with a one-liner with scanl1 :: (a -> a -> a) -> [a] -> [a]
:
QUESTION
There isn't a Genera topic on stackoverflow, but I thought I'd take the chance that one of the (probably) 5 people in the world using it might be here; no harm in trying.
I've run into the situation where a few of the systems I'm working with use pretty printing, which is not implemented on Genera. I've managed to work around the problem in my own system by using the predecessor of pretty printing, XP. Looking at the code in xp-code.lisp
and comparing it to that in CCL, it's clear where CCL got its pretty printing functions from.
One solution, now proving inadequate, is to have a top-level eval that does an (xp::install :package my-package)
and resume from the redefinition warnings. The problem is that when one of the third-party systems is compiled, they too complain about pretty printing features that are not implemented, so I'd have to install XP in each of these other packages that want pretty printing.
What really needs to happen is for XP to be installed in the common-lisp
package, because all of these other systems are going to :use :cl
and expect to have a fully functional pretty printing system.
That's not so easy though; the CL
package is locked and each XP symbol requires multiple confirms, and a type 'yes', to get it into the CL package. The documentation for External-only Packages and Locking
suggests that:
To set up an external-only package, it can be temporarily unlocked and then the desired set of symbols interned in it
but no where does it say how to unlock a package, and the Document Examiner isn't turning up much.
I also have to stop and wonder if I'm barking up the wrong tree. XP was written with Genera in mind, and there are conditionalisations in the code for the platform. It shouldn't be so hard to install using the install
function; and I wonder if I'm missing something obvious.
Does anyone out there know how to unlock the CL
package, or the proper way install XP in Genera? The included instructions for XP appear to be out of date.
ANSWER
Answered 2022-Feb-22 at 10:55I figured it out:
QUESTION
I am trying to encode a small lambda calculus with algebraic datatypes in Scheme. I want it to use lazy evaluation, for which I tried to use the primitives delay
and force
. However, this has a large negative impact on the performance of evaluation: the execution time on a small test case goes up by a factor of 20x.
While I did not expect laziness to speed up this particular test case, I did not expect a huge slowdown either. My question is thus: What is causing this huge overhead with lazy evaluation, and how can I avoid this problem while still getting lazy evaluation? I would already be happy to get within 2x the execution time of the strict version, but faster is of course always better.
Below are the strict and lazy versions of the test case I used. The test deals with natural numbers in unary notation: it constructs a sequence of 2^24
suc
s followed by a zero
and then destructs the result again. The lazy version was constructed from the strict version by adding delay
and force
in appropriate places, and adding let
-bindings to avoid forcing an argument more than once. (I also tried a version where zero
and suc
were strict but other functions were lazy, but this was even slower than the fully lazy version so I omitted it here.)
I compiled both programs using compile-file
in Chez Scheme 9.5 and executed the resulting .so
files with petite --program
. Execution time (user only) for the strict version was 0.578s, while the lazy version takes 11,891s, which is almost exactly 20x slower.
ANSWER
Answered 2021-Dec-28 at 16:24This sounds very like a problem that crops up in Haskell from time to time. The problem is one of garbage collection.
There are two ways that this can go. Firstly, the lazy list can be consumed as it is used, so that the amount of memory consumed is limited. Or, secondly, the lazy list can be evaluated in a way that it remains in memory all of the time, with one end of the list pinned in place because it is still being used - the garbage collector objects to this and spends a lot of time trying to deal with this situation.
Haskell can be as fast as C, but requires the calculation to be strict for this to be possible.
I don't entirely understand the code, but it appears to be recursively creating a longer and longer list, which is then evaluated. Do you have the tools to measure the amount of memory that the garbage collector is having to deal with, and how much time the garbage collector runs for?
QUESTION
could you guys please help me creating a next and previous buttons ? I've been struggling because of my bad javascript . I saw some people use Jquery and almost all Javascript. I'm practicing Javascript so there are a lot of things I don't know. Thank you very much.
Wants: Next / Previous button to go to next page and go back page if users want to read again that page.
Link of my demo: https://jsfiddle. net/hioihia123/zgjswtay/3/
...ANSWER
Answered 2021-Dec-19 at 04:40Can you simply add the Previous
and Next
buttons at the footer or somewhere you'd prefer, and link to appropriate pages? Won't that be simple enough in your case?
QUESTION
I do not understand this:
...ANSWER
Answered 2021-Nov-15 at 19:03boundp
is for determining whether symbols are bound in the global environment. Note the following two examples from the HyperSpec:
QUESTION
In Scheme, the function f
below is not visible outside its enclosing let
:
ANSWER
Answered 2021-Oct-09 at 14:31From common lisp hyperspec:
Evaluating defun
causes function-name to be a global name for the function specified by the lambda expression
QUESTION
Say that I am connected to a remote Lisp using swank/slime. I have a data file on my local machine on disk or, perhaps, in an emacs buffer. I want to process this file using the remote Lisp.
I can obviously drop out to a shell and scp the file to the server, load the file, process it, close, delete the file so that I don't make a mess on the server.
I can also paste the file into the repl:
...ANSWER
Answered 2021-Oct-01 at 15:50Have you tried compiling the buffer directly (rather than loading the file)? This would only help if the buffer is compile-able, of course.
This previous answer seems relevant (Load remote Lisp files):
For your particular case, I suggest you compile the buffer (select the whole buffer
C-x h
, thenC-c C-c
), not the file (C-c C-k
).
The annoyance is that this changes the buffer's point and mark. Hopefully, you won't be compiling a whole buffer all the time.
QUESTION
I was playing around with Haskell's parsec
library. I was trying to parse a hexadecimal string of the form "#x[0-9A-Fa-f]*"
into an integer. This the code I thought would work:
ANSWER
Answered 2021-Sep-29 at 14:33You need to place eof
at the end.
QUESTION
In the source code of SBCL's y-or-n-p
, I see (declare (explicit-check))
:
ANSWER
Answered 2021-Sep-28 at 15:49Based on the following sources in the code, it appears that explicit-check
indicates that the types associated with function parameters, as declared by an FTYPE
declaration, are not automatically checked but checked explicitly (manually).
This avoids having redundant checks when some function f
dispatches on type of one argument a
to a specialized function f_a
whose signature is declared by FTYPE
. Without the explicit-check
in f_a
, the type of a
would be checked twice, once during type dispatch, and once when entering the function.
src/compiler/ir1-translators.lisp
QUESTION
As an attempt to learn more about call/cc
in general I saw How does the yin-yang puzzle work? question and this explaination about the yin-yang puzzle:
ANSWER
Answered 2021-Aug-04 at 12:52i think your problem that yin
and yang
will become Continuation
and they don't call together but only yang
nested inside yin
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lisp
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