Lisp/Built-In Macros

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

Built-In Macros

Is DEFUN a macro?

Lisp Python
(when condition
    body...)
if condition:
    body...
(unless condition
    body...)
if not condition:
    body...
(cond (test-1 form*)
      (test-2 form*')
      ...)
if test-1:
    form*
elif test-2:
    form*
...
(and a b ...)
(or a, b ...)
Short-circuiting and/or operators.
(loop loop syntax) Advanced for loops. See below.
(dolist (var list-form) body-form*) Do body-form* for each var in list-form. Break with RETURN.
<tt>(dotimes (var count-form) body-form*) Do body-form* for var from 0 to count-form-1. Break with RETURN.
(do (''variable-definition*'')
    (''end-test-form'' ''result-form*'') 
  ''statement*'')
Advanced while loop. See below.

LOOP

DO