Hot answers tagged

20 votes

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 ...
J David Smith's user avatar
17 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 ...
Emacs User's user avatar
  • 5,603
13 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. ...
wvxvw's user avatar
  • 11.3k
9 votes

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 ...
muffinmad's user avatar
  • 2,290
8 votes

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 ...
Tobias's user avatar
  • 32.8k
7 votes

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

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

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))
ebpa's user avatar
  • 7,389
3 votes

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 ...
Drew's user avatar
  • 76.3k
3 votes

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 ...
phils's user avatar
  • 49.7k
2 votes

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 ...
sds's user avatar
  • 5,958
1 vote

Is there a code example demonstrating a meaningful usage of the built-in function `funcall`?

Virtually all of the "real" examples are variations of the following theme: you have a list of functions and you want to call each function in turn (e.g. hooks are lists of functions - when ...
NickD's user avatar
  • 28.2k

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