|
52 | 52 | (iota 6) ⇒ (0 1 2 3 4 5) |
53 | 53 | (iota 4 2.5 -2) ⇒ (2.5 0.5 -1.5 -3.5) |
54 | 54 |
|
55 | | - (define my-list '(a b c d e)) |
56 | | - (list-ref my-list 2) ;; nth element of a list |
| 55 | + (define my-list '(a0 b1 c2 d3 e4)) |
| 56 | + (list-ref my-list 2) ;; => c2 (nth element of a list) |
57 | 57 |
|
58 | 58 | https://sourcegraph.com/search |
59 | 59 | https://sourcehut.org |
|
118 | 118 | (unspecified? *unspecified*) ; => #t |
119 | 119 | ;; The evaluated expression has no result specified: |
120 | 120 | (equal? (when #f #t) *unspecified*) ; => #t |
| 121 | + ;; However: |
| 122 | + (equal? (when #f #t)) ; => #t |
| 123 | + (equal? *unspecified*) ; => #t |
| 124 | + ;; *unspecified* is truthy. WTF!?! |
| 125 | + (if (when #f #t) #t #f) ; => #t |
| 126 | + (if *unspecified* #t #f) ; => #t |
121 | 127 | ;; *unspecified* is a value apart from both: empty list and boolean false |
122 | | - (eq? *unspecified* '()) ; => #f |
123 | | - (eq? *unspecified* #f) ; => #f |
124 | | - (eq? *unspecified* #t) ; => #f |
| 128 | + (eq? *unspecified* '()) ; => #f |
| 129 | + (eq? *unspecified* #f) ; => #f |
| 130 | + (eq? *unspecified* #t) ; => #f |
125 | 131 |
|
126 | 132 | Tail Call Optimisation |
127 | 133 | the compiler will rewrite the recursive form into a serialised iterative form. |
|
505 | 511 | (odd? (lambda (n) (if (zero? n) #f (even? (- n 1)))))) |
506 | 512 | (even? 88)) |
507 | 513 |
|
| 514 | + (use-modules (srfi srfi-88)) ; provides keyword objects |
508 | 515 | (keyword? #:foo) ;; => #t |
509 | 516 | ;; (keyword? :foo) ;; => error |
510 | 517 | ;; (keyword? foo:) ;; => error |
|
566 | 573 | Scheme[2][3] and are available in the GNU Guile implementation of that |
567 | 574 | language. |
568 | 575 | } |
| 576 | + |
| 577 | +@block{@block-name{Exactness} |
| 578 | + ;; https://www.gnu.org/software/guile/docs/docs-2.0/guile-ref/Exactness.html |
| 579 | + (exact? 2) ; ⇒ #t |
| 580 | + (exact? 0.5) ; ⇒ #f |
| 581 | + (exact? (/ 2)) ; ⇒ #t |
| 582 | + (inexact->exact 0.5) ; ⇒ 1/2 |
| 583 | + ;; 12/10 is not exactly representable as a double (on most platforms). |
| 584 | + ;; However, when reading a decimal number that has been marked exact with the |
| 585 | + ;; "#e" prefix, Guile is able to represent it correctly. |
| 586 | + (inexact->exact 1.2) ; ⇒ 5404319552844595/4503599627370496 |
| 587 | + #e1.2 ; ⇒ 6/5 |
| 588 | +} |
0 commit comments