Skip to content

Commit becd149

Browse files
committed
Notes
1 parent d2305a0 commit becd149

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

notes/guix-guile-nix/guile.scrbl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@
264264

265265
@block{@block-name{Various code snippets}
266266
@lisp{
267+
(use-modules (srfi srfi-111)) ; Mutable containers
268+
(define (incr! a-box) (set-box! a-box (+ (unbox a-box) 1)))
269+
(define y (box 0))
270+
(incr! y)
271+
(unbox y) ; => 1
272+
267273
(use-modules (ice-9 match))
268274
(match (list 1 2) [(f s) (list "f: " f "s: " s)]) ; => ("f: " 1 "s: " 2)
269275

@@ -539,12 +545,17 @@
539545
}
540546

541547
@block{@block-name{Equality}
542-
| eqv? | (eqv? 3 (+ 1 2)) => #t (eqv? 1 1.0) => #f |
543-
;;
544-
| | returns `#t' if X and Y are: |
545-
| equal? | the same type, and their contents or value are equal |
546-
| eq? | the same object, except for numbers and characters |
547-
| = | numerically equal |
548+
| Data type | Interned? | Compared by | Example true? | Preferred |
549+
| ------------- | --------- | ----------- | ------------------ | --------- |
550+
| Symbol | Yes | Identity | (eq? 'a 'a) | eq? |
551+
| Keyword | Yes | Identity | (eq? #:a #:a) | eq? |
552+
| Boolean | Yes | Identity | (eq? #t #t) | eq? |
553+
| Character | No (value) | Value | (eqv? #\a #\a) | eqv? |
554+
| Number | No | Value | (= 3 3) | = |
555+
| String | No | Content | (string=? "a" "a") | string=? |
556+
| List / Vector | No | Structure | (equal? '(1) '(1)) | equal? |
557+
| | | | | |
558+
Use `equal?` when unsure but want safe generality:
548559
}
549560

550561
@block{@block-name{SXML}

0 commit comments

Comments
 (0)