Skip to content

Commit 7704995

Browse files
authored
Add module generalized-arrays (#369)
test-arrays.scm is a test program, girl.pgm is an input file, edge-test.pgm and sharper-test.scm are output files. Compiled and tested with gambc-4_7_9, gambit-4_9_2, and v4.9.3-1234-g6acd87df 20201007225704.
1 parent 2b09d36 commit 7704995

File tree

7 files changed

+8110
-0
lines changed

7 files changed

+8110
-0
lines changed

modules/generalized-arrays/edge-test.pgm

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#|
2+
Copyright 2020 Bradley J Lucier.
3+
All Rights Reserved.
4+
5+
Permission is hereby granted, free of charge,
6+
to any person obtaining a copy of this software
7+
and associated documentation files (the "Software"),
8+
to deal in the Software without restriction,
9+
including without limitation the rights to use, copy,
10+
modify, merge, publish, distribute, sublicense,
11+
and/or sell copies of the Software, and to permit
12+
persons to whom the Software is furnished to do so,
13+
subject to the following conditions:
14+
15+
The above copyright notice and this permission notice
16+
(including the next paragraph) shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
20+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
21+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
23+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
24+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25+
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27+
OTHER DEALINGS IN THE SOFTWARE.
28+
|#
29+
30+
(##namespace
31+
(""
32+
;; Miscellaneous Functions
33+
translation? permutation?
34+
35+
;; Intervals
36+
make-interval interval?
37+
interval-dimension
38+
interval-lower-bound interval-upper-bound
39+
interval-lower-bounds->list interval-upper-bounds->list
40+
interval-lower-bounds->vector interval-upper-bounds->vector
41+
interval= interval-volume interval-subset? interval-contains-multi-index?
42+
interval-projections
43+
interval-for-each
44+
interval-dilate interval-intersect interval-translate interval-permute
45+
interval-rotate interval-scale interval-cartesian-product
46+
47+
;; Storage Classes
48+
make-storage-class storage-class?
49+
storage-class-getter storage-class-setter
50+
storage-class-checker storage-class-maker storage-class-copier
51+
storage-class-length storage-class-default
52+
generic-storage-class
53+
s8-storage-class s16-storage-class s32-storage-class s64-storage-class
54+
u1-storage-class
55+
u8-storage-class u16-storage-class u32-storage-class u64-storage-class
56+
f8-storage-class f16-storage-class f32-storage-class f64-storage-class
57+
c64-storage-class c128-storage-class
58+
59+
;; Arrays
60+
make-array array?
61+
array-domain array-getter array-dimension
62+
mutable-array? array-setter
63+
specialized-array-default-safe? specialized-array-default-mutable?
64+
make-specialized-array specialized-array?
65+
array-storage-class array-indexer array-body array-safe?
66+
array-elements-in-order?
67+
specialized-array-share
68+
array-copy
69+
array-curry array-extract array-tile array-translate array-permute
70+
array-rotate array-reverse array-sample
71+
array-outer-product
72+
array-map array-for-each
73+
array-fold array-fold-right array-reduce
74+
array-any array-every
75+
array->list list->array
76+
array-assign!
77+
specialized-array-reshape
78+
array-ref array-set!
79+
))
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#|
2+
Copyright 2020 Bradley J Lucier.
3+
All Rights Reserved.
4+
5+
Permission is hereby granted, free of charge,
6+
to any person obtaining a copy of this software
7+
and associated documentation files (the "Software"),
8+
to deal in the Software without restriction,
9+
including without limitation the rights to use, copy,
10+
modify, merge, publish, distribute, sublicense,
11+
and/or sell copies of the Software, and to permit
12+
persons to whom the Software is furnished to do so,
13+
subject to the following conditions:
14+
15+
The above copyright notice and this permission notice
16+
(including the next paragraph) shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
20+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
21+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
23+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
24+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25+
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27+
OTHER DEALINGS IN THE SOFTWARE.
28+
|#
29+
30+
(cond-expand
31+
(gambit-c
32+
33+
;; These are routines used internally in generalized-arrays.scm
34+
;; that are defined in gambit-4_9_2 but not gambc-4_7_9.
35+
36+
;; They're in a separate include file because we need them
37+
;; at compile time in macros, so this file is also included
38+
;; in the macros.
39+
40+
;; From SRFI-1
41+
42+
(define (iota count #!optional (start 0) (step 1))
43+
(let loop ((i count) (result '()))
44+
(if (> i 0)
45+
(let ((i (- i 1)))
46+
(loop i (cons (+ start (* step i)) result)))
47+
result)))
48+
49+
(define (take x i)
50+
(let loop ((probe x)
51+
(j i)
52+
(rev-result '()))
53+
(if (> j 0)
54+
(loop (if (pair? probe) (cdr probe) (error "take: short list" x i))
55+
(- j 1)
56+
(cons (car probe) rev-result))
57+
(reverse rev-result))))
58+
59+
(define (drop x i)
60+
(let loop ((probe x)
61+
(j i))
62+
(if (> j 0)
63+
(loop (if (pair? probe) (cdr probe) (error "drop: short list" x i))
64+
(- j 1))
65+
probe)))
66+
67+
;; From later Gambits
68+
69+
(define (exact-integer? obj)
70+
(and (integer? obj)
71+
(exact? obj)))
72+
)
73+
(else))

0 commit comments

Comments
 (0)