File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 264264
265265@block{@block-name{Various code snippets}
266266 @lisp{
267+ (use-modules (ice-9 match ))
268+ (match (list 1 2 ) [(f s) (list "f: " f "s: " s)]) ; => ("f: " 1 "s: " 2)
269+
270+ (use-modules (srfi srfi-9)) ; define-record-type
271+ (use-modules (ice-9 match ))
272+ (let ()
273+ (define-record-type person
274+ (make-person name friends)
275+ person?
276+ (name person-name)
277+ (friends person-friends))
278+ ;;
279+ (letrec ((alice (make-person "Alice " (delay (list bob))))
280+ (bob (make-person "Bob " (delay (list alice)))))
281+ (match alice
282+ (($ person name (= force (($ person "Bob " ))))
283+ (list 'friend-of-bob name))
284+ (_ #f ))))
285+ ;; => (friend-of-bob "Alice")
286+
267287 (use-modules) (srfi srfi-13) ;; String Library
268288 (string->number "1 " ) ;; => 1
269289 (string->number* "1 " ) ;; from (guix ui)
You can’t perform that action at this time.
0 commit comments