(apply (lambda (a b c) #t) (list 1 2 3))
-> a:1 b:2 c:3
(apply (lambda (a b . c) #t) (list 1 2 3 4 5))
-> a:1 b:2 c:(3 4 5)
(apply (lambda* (a #:optional b) #t) (list 1 2))
-> a:1 b:2. if a shorter list (list 1) where given instead, then a:1 b:#f
(apply (lambda* (a #:key (b 8) c) #t) (list 1 #:b 2 #:c 3))
the special #: keyword syntax of lambda* is used to differentiate from normal symbols.
unfortunately, the following does not work
(apply (lambda (a . b) #t) (pair 1 2))
eq, eqv, equal
eq?
tests whether two objects are the same (pointer equality).eqv?
extends eq?
by treating numbers and characters with the same value as equivalent.equal?
performs deep structural comparison, suitable for lists, vectors, strings, etc.eval returns objects
(eval expr module)
evaluates an expression and returns the resulting Scheme object, not its printed form.exact->inexact: floats are inexact, integers are exact
(exact->inexact 3)
yields 3.0
; the reverse is possible with (inexact->exact)
.file tree walk
(scandir path predicate)
to list directory entries.(file-is-directory? file)
to detect subdirectories.map with multiple arguments
(map proc lst1 lst2 ...)
applies proc
to elements taken simultaneously from each list.multiple hash-table interfaces, multiple exception interfaces
catch
), SRFI-34, and SRFI-18.named let defines and calls a procedure
let
defines a recursive procedure and invokes it immediately.define
.pattern matching with (ice-9 match)
(use-modules (ice-9 match))
enables match
expressions.sandbox evaluation
the guile c interface
libguile
provides a C API to embed Scheme or expose C functions to Scheme.scm_c_define_gsubr
, scm_from_int
, etc., for interoperation.the use of begin on the toplevel
begin
sequences expressions but does not introduce a new scope at the top level.uniform vectors and c
u8vector
, f64vector
, etc.) store homogenous, fixed-type data.the identity function
(define (identity x) x)
is the canonical form.values
in multiple-value contexts.guile procedure index
info guile
or online, useful for API discovery.continuation passing style
call/cc
.lists are chains of pairs
car
holds a value; cdr
points to the next pair or ()
.