Lisp/Functions/Built-In

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

Built-In Functions

(funcall #'func-name param1 param2 ...)
Calls the function as if (func-name param1 param2 ...). When you know the number of params, use this.
(apply #'func-name params)
Calls the function as if (func-name param1 param2 ...). When you don't know the number of params, use this.

Math Functions

= Tests that all the items are numerically equal, or that none are unequal.
/= Tests that all the items are numerically unequal, or that none are equal.
<, >, <=, >= Tests that Compares each item with its neighbor, one at a time.
min, max Returns the min/max value.
LOG, EXP, EXPT, SIN, COS, TAN, ASIN, ACOS, ATAN, SINH, COSH, TANH, ASINH, ACOSH, ATANH Higher-level functions

String Functions

CHAR=, CHAR/=, CHAR<, CHAR>, CHAR<=, CHAR>= Case-sensitive compare, single char
CHAR-EQUAL, CHAR-NOT-EQUAL, CHAR-LESSP, CHAR-GREATERP, CHAR-NOT-GREATERP, CHAR-NOT-LESSP Case-insensitive compare, single char
STRING=, STRING/=, STRING<, STRING>, STRING<=, STRING>= Case-sensitive compare, many chars
STRING-EQUAL, STRING-NOT-EQUAL, STRING-LESSP, STRING-GREATERP, STRING-NOT-GREATERP, STRING-NOT-LESSP Case-insensitive compare, many chars

Logical Operations

True and False

Only NIL is false. Everything else is true. T is also true.

Equality Tests

  • = : Compare numbers
  • CHAR= : Compare single characters
  • etc...
  • EQ : Object identity test. Note: (EQ 3 3) may fail, depending on the implementation. Even (EQ x x) may fail if x is a number or character.
  • EQL : Compares class and values. (EQL 3 3) is true but (EQL 3 3.0) is false. Recommendation: NEVER USE EQ.
  • EQUAL : Compares recursively with EQUAL, falling back to EQL when an EQUAL isn't available.
  • EQUALP: Like EQUAL, and falls back to EQL, but for many types it will detect mathematical equivalence. For instance (EQUALP 1 1.0) is true.