Differences From
Artifact [833aa00a5f]:
1 -; ʞ / struct.scm
1 +; [ʞ] struct.scm
2 +; ~ lexi hale <lexi@hale.su>
3 +; © affero general public license
4 +; > (load "lib/struct.scm")
2 5 ;
3 6 ; generates immutable, relatively efficient structs. declare
4 7 ; a struct type x with
5 8 ; (define x (struct 'field1 'field2)
6 9 ; create a record y of that type with
7 10 ; (define y (x 123 456))
8 11 ; access field1 of record y with
9 12 ; (y 'field1)
10 13 ; update field2 of record y with
11 14 ; (y 'field2 123) → new record (field1 = 123; field2 = 123)
12 15 ;
13 -; this unit also includes a few utility function that chicken
14 -; scheme conveniently "forgot." i apologize for the implementation
15 -; of (list-head). i was very tired.
16 +; this unit also includes a few utility function that
17 +; chicken scheme conveniently "forgot." i apologize for
18 +; the implementation of (list-head). i was very tired.
16 19
17 20 ; return a sub-list of lst up to ct (inverse of list-tail)
18 21 (define (list-head lst ct)
19 22 (let* ([reverse-lst (reverse lst)]
20 23 [idx (- (length lst) (+ 1 ct))])
21 24 (reverse (list-tail reverse-lst idx))))
22 25 ; i'm not proud of this