The Urn Logo

core/base

(-and a b)

Defined at lib/core/base.lisp:344:2

Return the logical conjunction of values A and B.

As this is a function rather than a macro, it can be used as a variable. However, each argument is evaluated eagerly. See and for a lazy version.

(-or a b)

Defined at lib/core/base.lisp:336:2

Return the logical disjunction of values A and B.

As this is a function rather than a macro, it can be used as a variable. However, each argument is evaluated eagerly. See or for a lazy version.

(<=> p q)

Macro defined at lib/core/base.lisp:320:2

Bidirectional implication. (<=> a b) means that (=> a b) and (=> b a) both hold.

Example:

> (<=> (> 3 1) (< 1 3))
out = true
> (<=> (> 1 3) (< 3 1))
out = true
> (<=> (> 1 3) (< 1 3))
out = false

(=> p q)

Macro defined at lib/core/base.lisp:310:2

Logical implication. (=> a b) is equivalent to (or (not a) b).

Example:

> (=> (> 3 1) (< 1 3))
out = true

(and a b &rest)

Macro defined at lib/core/base.lisp:274:2

Return the logical and of values A and B, and, if present, the logical and of all the values in REST.

Each argument is lazily evaluated, only being computed if the previous argument returned a truthy value. This will return the last argument to be evaluated.

Example:

> (and 1 2 3)
out = 3
> (and (> 3 1) (< 3 1))
out = false

(apply f &xss xs)

Defined at lib/core/base.lisp:438:2

Apply the function F using XS as the argument list, with XSS as arguments before XS is spliced.

Example:

> (apply + '(1 2))
out = 3
> (apply + 1 '(2))
out = 3

arg

Defined at lib/core/base.lisp:379:1

The arguments passed to the currently executing program

(cons x xs)

Defined at lib/core/base.lisp:145:2

Add X to the start of the list XS. Note: this is linear in time.

(const-val val)

Defined at lib/core/base.lisp:391:2

Get the actual value of VAL, an argument to a macro.

Due to how macros are implemented, all values are wrapped as tables in order to preserve positional data about nodes. You will need to unwrap them in order to use them.

(defmacro name args &body)

Macro defined at lib/core/base.lisp:125:1

Define NAME to be the macro given by (lambda ARGS @BODY), with optional metadata at the start of BODY.

(defun name args &body)

Macro defined at lib/core/base.lisp:119:1

Define NAME to be the function given by (lambda ARGS @BODY), with optional metadata at the start of BODY.

else

Defined at lib/core/base.lisp:9:1

else is defined as having the value true. Use it as the last case in a cond expression to increase readability.

(for ctr start end step &body)

Macro defined at lib/core/base.lisp:224:2

Iterate BODY, with the counter CTR bound to START, being incremented by STEP every iteration until CTR is outside of the range given by [START .. END].

Example:

> (with (x '())
.   (for i 1 3 1 (push-cdr! x i))
.   x)
out = (1 2 3)

(for-pairs vars tbl &body)

Macro defined at lib/core/base.lisp:352:2

Iterate over TBL, binding VARS for each key value pair in BODY.

Example:

> (let [(res '())
.       (struct { :foo 123 })]
.   (for-pairs (k v) struct
.     (push-cdr! res (list k v)))
.     res)
out = (("foo" 123))

gensym

Defined at lib/core/base.lisp:200:1

Create a unique symbol, suitable for using in macros

(if c t b)

Macro defined at lib/core/base.lisp:162:2

Evaluate T if C is true, otherwise, evaluate B.

Example

> (if (> 1 3) "> 1 3" "<= 1 3")
out = "<= 1 3"

(list &xs)

Defined at lib/core/base.lisp:134:2

Return the list of variadic arguments given.

Example:

> (list 1 2 3)
out = (1 2 3)

(n x)

Defined at lib/core/base.lisp:14:1

Get the length of list X

(not expr)

Defined at lib/core/base.lisp:189:2

Compute the logical negation of the expression EXPR.

Example:

> (with (a 1)
.   (not (= a 1)))
out = false

(or a b &rest)

Macro defined at lib/core/base.lisp:292:2

Return the logical or of values A and B, and, if present, the logical or of all the values in REST.

Each argument is lazily evaluated, only being computed if the previous argument returned a falsey value. This will return the last argument to be evaluated.

Example:

> (or 1 2 3)
out = 1
> (or (> 3 1) (< 3 1))
out = true

(progn &body)

Macro defined at lib/core/base.lisp:149:2

Group a series of expressions together.

Example

> (progn
.   (print! 123)
.   456)
123
out = 456

(quasiquote val)

Macro defined at lib/core/base.lisp:424:2

Quote VAL, but replacing all unquote and unquote-splice with their actual value.

Be warned, by using this you lose all macro hygiene. Variables may not be bound to their expected values.

Example:

> (with (x 1)
.   ~(+ ,x 2))
out = (+ 1 2)

(slice xs start finish)

Defined at lib/core/base.lisp:22:1

Take a slice of XS, with all values at indexes between START and FINISH (or the last entry of XS if not specified).

(unless c &body)

Macro defined at lib/core/base.lisp:176:2

Evaluate BODY if C is false, otherwise, evaluate nil.

(values-list &xs)

Macro defined at lib/core/base.lisp:452:2

Return multiple values, one per element in XS.

Example:

> (print! (values-list 1 2 3))
1   2   3
out = nil

(when c &body)

Macro defined at lib/core/base.lisp:172:2

Evaluate BODY when C is true, otherwise, evaluate nil.

(while check &body)

Macro defined at lib/core/base.lisp:251:2

Iterate BODY while the expression CHECK evaluates to true.

Example:

> (with (x 4)
.   (while (> x 0) (dec! x))
.   x)
out = 0

(with var &body)

Macro defined at lib/core/base.lisp:270:2

Bind the single variable VAR, then evaluate BODY.

Undocumented symbols

  • * Native defined at lib/lua/basic.lisp:10:1
  • + Native defined at lib/lua/basic.lisp:8:1
  • - Native defined at lib/lua/basic.lisp:9:1
  • .. Native defined at lib/lua/basic.lisp:14:1
  • / Native defined at lib/lua/basic.lisp:11:1
  • /= Native defined at lib/lua/basic.lisp:2:1
  • < Native defined at lib/lua/basic.lisp:3:1
  • <= Native defined at lib/lua/basic.lisp:4:1
  • = Native defined at lib/lua/basic.lisp:1:1
  • > Native defined at lib/lua/basic.lisp:5:1
  • >= Native defined at lib/lua/basic.lisp:6:1
  • (car xs) Defined at lib/core/base.lisp:131:1
  • (cdr xs) Defined at lib/core/base.lisp:132:1
  • concat Native defined at lib/lua/table.lisp:1:1
  • (eighth &rest) Defined at lib/core/base.lisp:470:1
  • error Native defined at lib/lua/basic.lisp:24:1
  • expt Native defined at lib/lua/basic.lisp:13:1
  • (fifth &rest) Defined at lib/core/base.lisp:470:1
  • (first &rest) Defined at lib/core/base.lisp:470:1
  • (fourth &rest) Defined at lib/core/base.lisp:470:1
  • get-idx Native defined at lib/lua/basic.lisp:34:1
  • getmetatable Native defined at lib/lua/basic.lisp:25:1
  • (lambda ll &body) Macro defined at lib/core/base.lisp:54:1
  • len# Native defined at lib/lua/basic.lisp:19:1
  • (let* vars &body) Macro defined at lib/core/base.lisp:180:2
  • mod Native defined at lib/lua/basic.lisp:12:1
  • (ninth &rest) Defined at lib/core/base.lisp:470:1
  • pcall Native defined at lib/lua/basic.lisp:31:1
  • print Native defined at lib/lua/basic.lisp:32:1
  • require Native defined at lib/lua/basic.lisp:39:1
  • (second &rest) Defined at lib/core/base.lisp:470:1
  • set-idx! Native defined at lib/lua/basic.lisp:36:1
  • setmetatable Native defined at lib/lua/basic.lisp:41:1
  • (seventh &rest) Defined at lib/core/base.lisp:470:1
  • (sixth &rest) Defined at lib/core/base.lisp:470:1
  • (tenth &rest) Defined at lib/core/base.lisp:470:1
  • (third &rest) Defined at lib/core/base.lisp:470:1
  • tonumber Native defined at lib/lua/basic.lisp:42:1
  • tostring Native defined at lib/lua/basic.lisp:43:1
  • type# Native defined at lib/lua/basic.lisp:44:1
  • unpack Native defined at lib/lua/table.lisp:7:1
  • xpcall Native defined at lib/lua/basic.lisp:45:1