2019-06-17

guile scheme usage examples

handling command-line arguments

lambda pattern matching

(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))

other

  • eq, eqv, equal
  • eval returns objects
  • exact->inexact
  • file tree walk
  • folding and mapping
  • lambda*
  • map with multiple arguments
  • multiple hash-table implementations, multiple exception implementations
  • named let
  • pair-fold
  • parallel map
  • pattern matching with (ice-9 match)
  • sandbox evaluation
  • the guile c interface
  • the use of begin on the toplevel
  • unfold
  • uniform vectors and c