Skip to main content
6 votes
Accepted

Best Practice - Where to declare variables in Common Lisp?

Your approach is correct: we bind (rather than declare, as in other languages) variables exactly where we need them. (In your case, however, you are using h-offset in the 1st half of your function, ...
sds's user avatar
  • 891
4 votes
Accepted

Why are Lisp programs a sequence of S-expressions and not a single list?

One of the reasons is that a single s-expression is slighty less practical in actual programming in many cases. Remember, the evaluator in Lisp works like this: it reads a form and then evaluates it. ...
Rainer Joswig's user avatar
3 votes

Python decorators and Lisp macros

A decorator (be it in Python or in any other - functional programming - language) is just a function which accepts an original (to-be-decorated) function (and sometimes more additional arguments), and ...
Gwang-Jin Kim's user avatar
3 votes

Do non-pure interpreters still make the guarantees of functional programming?

The guarantees provided by a functional programming language apply to the behavior of programs written in that language, not the implementation itself. "No side effects" means that there are no side ...
Sean Lynch's user avatar
2 votes

Why is studying a Lisp interpreter in lisp so important?

The exercise in question is a self-interpreter (or meta-circular evaluator) - an interpreter which is powerful enough to execute its own source code. The point of the self-interpreter is to examine ...
JacquesB's user avatar
  • 62.3k
2 votes

Why is studying a Lisp interpreter in lisp so important?

A Lisp interpreter written in Lisp can be given as a weekly or even overnight homework assignment. Whereas making a from-scratch interpreted language would be more of a semester project. A Lisp ...
Kaz's user avatar
  • 3,702
2 votes

Scheme's define in Common Lisp

You don't have to use LET when using DEFUN: you can define local variables in the parameter list: (defun foo (a) (let ((b (expt a 3))) (+ a b))) is also (defun foo (a &aux (b (expt a 3))) ...
Rainer Joswig's user avatar
1 vote

Scheme's define in Common Lisp

Yes, of course this is possible: CL is a language which excels in creating new languages: that's what Lisps are for. You could start with something like binding. This is a macro which works so that (...
ignis volens's user avatar
1 vote

Why are Lisp programs a sequence of S-expressions and not a single list?

It would seem logical and natural that program is a list of s-expressions to execute (as it is already implicitly understood just looks like missing explicit list declaration). Only if you think of ...
Telastyn's user avatar
  • 110k
1 vote

Wrapping my mind around prefix notation?

When it is indented and aligned, prefix gives you a diagram resembling logic gates (but of course for any kind of function) (and (or x y) (not (and z ...
Kaz's user avatar
  • 3,702

Only top scored, non community-wiki answers of a minimum length are eligible