Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

16 votes

When/why should I use progn?

The most important reason for progn is described in the first line of the progn documentation (emphasis added): progn is a special form that causes each of its arguments to be evaluated in sequence ...
user avatar
  • 5,325
15 votes
Accepted

When/why should I use progn?

progn is typically used when dealing with macros. Some macros (use-package is a macro, last I checked) accept only 1 form, where others consume all remaining forms. progn is used in the former case ...
user avatar
12 votes

When/why should I use progn?

A better way to understand what progn is is by comparing it to the family: prog1 and prog2. The n or 1 or 2 part of the name stands for the statement from the list whose result you are interested in. ...
user avatar
  • 10.8k
8 votes
Accepted

Find out, which mode is in use

See major-mode variable to find out major mode: Symbol for current buffer’s major mode. See cond function to do something depending on mode: Try each clause until one succeeds. Each clause ...
user avatar
  • 2,175
8 votes
Accepted

Shortening trees list with (setcdr (nthcdr 2 trees) nil)

Formal answer In your expanded example you set the variable trees to a new value in: (setq trees '(pine birch)) That is not what happens in the original example. In the original example really the ...
user avatar
  • 29.9k
6 votes

How to properly use emacs and slime to program in Common Lisp

It is simple as: Open emacs Open your lisp file with fibonachi function Issue M-x slime Place you cursor over fibonachi function and press C-c C-c to evaluate/compile it in Slime. switch to slime ...
user avatar
  • 1,286
5 votes
Accepted

How to pop an arbitrary element from a list?

Simply (pop (nthcdr n my-list)): (let ((x '(a b c d e))) (list (pop (nthcdr 2 x)) x)) ;; => (c (a b d e))
user avatar
  • 6,794
3 votes
Accepted

how to specify an Cyclic list in lisp?

See the Elisp manual, node Circular Objects. A circular list is one way to implement an infinite list. For example (from the doc), this creates a list in which the first element recurs as the third ...
user avatar
  • 69.2k
3 votes
Accepted

Confused by what Paul Graham says about locality in his book "On Lisp"

He's talking about side-effects of calling a function (and whether they can be avoided). A purely functional language would not allow a call to f(x) to modify the value of the argument being passed to ...
user avatar
  • 43.1k
2 votes
Accepted

Adjusting indenting for lisp if statements

Why is Emacs so weird? Emacs indents lisp code as if it were Emacs Lisp, where if accepts unlimited else forms; unlike in Common Lisp, where if accepts at most 3 arguments. What to do? Tell Emacs ...
user avatar
  • 5,437

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