forked from okuoku/xitomatl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindexes.sls
32 lines (26 loc) · 835 Bytes
/
indexes.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!r6rs
;; Copyright 2009 Derick Eddington. My MIT-style license is in the file named
;; LICENSE from the original collection this file is distributed with.
(library (xitomatl indexes)
(export
iota
enumerate)
(import
(rnrs)
(only (xitomatl define) define/?)
(only (xitomatl predicates) exact-non-negative-integer?)
(xitomatl generics))
(define (_iota n l)
(if (= n -1)
l
(_iota (- n 1) (cons n l))))
(define/? (iota (n exact-non-negative-integer?))
(_iota (- n 1) '()))
(define (_enumerate len)
(_iota (- len 1) '()))
(define-generic/temporal enumerate
(((x list?)) (_enumerate (length x)))
(((x vector?)) (_enumerate (vector-length x)))
(((x string?)) (_enumerate (string-length x)))
(((x bytevector?)) (_enumerate (bytevector-length x))))
)