Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Core Functions

lambda

Create anonymous (unnamed) functions.

Syntax:

(lambda (parameter ...) body)

Examples:

; Function that adds 1 to its argument
(lambda (x) (+ x 1))

; Function that gets the category from a transaction
(lambda (pair) (cdr (assoc 'category (cdr pair))))

Usage in transform:

kakei transform --program "(group-by table (lambda (pair) (cdr (assoc 'category (cdr pair)))))"

define

Define variables or functions for reuse within a program.

Syntax:

(define name value)

Examples:

; Define a constant
(define pi 3.14159)

; Define a function
(define (double x) (+ x x))

; Use the defined function
(double 5)  ; => 10

if

Conditional evaluation - execute different code based on a condition.

Syntax:

(if condition then-expr else-expr)

Examples:

; Check if a value is empty
(if (null? x) "empty" "not empty")

; Check equality
(if (equal? category "Food") "food-related" "other")