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, ...
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. ...
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 ...
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 ...
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 ...
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 ...
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)))
...
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
(...
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 ...
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
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
lisp × 112scheme × 20
clojure × 16
functional-programming × 15
common-lisp × 15
programming-languages × 11
macros × 11
haskell × 8
c × 7
language-design × 7
learning × 6
recursion × 4
object-oriented × 3
algorithms × 3
javascript × 3
python × 3
history × 3
scala × 3
self-improvement × 3
computer-science × 3
syntax × 3
artificial-intelligence × 3
sicp × 3
design × 2
c++ × 2