What exactly is a symbol in lisp/scheme?

In Scheme and Racket, a symbol is like an immutable string that happens to be interned so that symbols can be compared with eq? (fast, essentially pointer comparison). Symbols and strings are separate data types. One use for symbols is lightweight enumerations. For example, one might say a direction is either ‘north, ‘south, ‘east, or … Read more

LET versus LET* in Common Lisp

LET itself is not a real primitive in a Functional Programming Language, since it can replaced with LAMBDA. Like this: (let ((a1 b1) (a2 b2) … (an bn)) (some-code a1 a2 … an)) is similar to ((lambda (a1 a2 … an) (some-code a1 a2 … an)) b1 b2 … bn) But (let* ((a1 b1) (a2 … Read more

setq and defvar in Lisp

There are several ways to introduce variables. DEFVAR and DEFPARAMETER introduce global dynamic variables. DEFVAR optionally sets it to some value, unless it is already defined. DEFPARAMETER sets it always to the provided value. SETQ does not introduce a variable. (defparameter *number-of-processes* 10) (defvar *world* (make-world)) ; the world is made only once. Notice that … Read more

Common lisp error: “should be lambda expression”

Correct! The problem is in the line right after that, where it says ((cons nil lst) (append lst nil) (insertat nil lst 3) … The issue is the two opening parentheses. Parentheses can change meaning in special contexts (like the cond form you’re using), but in this context, the parentheses signify regular function application, just … Read more

Alan Kay’s Eval/Apply Einstein Moment

There are two different issues: First: Dynamic binding as a bug Not sure what he means, but generally in McCarthy’s EVAL the use of dynamic binding can be seen as a bug. He does not implement lexical scope for variables. The bug shows up for example here: http://www-formal.stanford.edu/jmc/recursive/node3.html See the functions maplist and diff. Both … Read more

How to compare two functions for equivalence, as in (λx.2*x) == (λx.x+x)?

It’s pretty well-known that general function equality is undecidable in general, so you’ll have to pick a subset of the problem that you’re interested in. You might consider some of these partial solutions: Presburger arithmetic is a decidable fragment of first-order logic + arithmetic. The universe package offers function equality tests for total functions with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)