List Operations
cons
Construct a pair (cons cell) - the fundamental building block of Lisp lists.
Syntax:
(cons first second)
Examples:
(cons 1 2) ; => (1 . 2)
(cons 1 ()) ; => (1)
(cons 1 (cons 2 ())) ; => (1 2)
Usage:
; Create a list with the first transaction only
(cons (car table) ())
car
Get the first element of a pair.
Syntax:
(car pair)
Examples:
(car (cons 1 2)) ; => 1
(car '(1 2 3)) ; => 1
(car table) ; => first transaction
Usage:
# Get the first transaction
kakei transform --program "(car table)"
cdr
Get the second element of a pair (everything after the first element).
Syntax:
(cdr pair)
Examples:
(cdr (cons 1 2)) ; => 2
(cdr '(1 2 3)) ; => (2 3)
(cdr table) ; => all transactions except first
Usage:
# Skip the first transaction
kakei transform --program "(cdr table)"