sunterlib/scsh/sequences/packages.scm

194 lines
6.5 KiB
Scheme
Raw Normal View History

2003-02-11 19:23:30 -05:00
; Copyright (c) 2003 RT Happe <rthappe at web de>
; See the file COPYING distributed with the Scheme Untergrund Library
2004-03-10 12:23:45 -05:00
;; the basic protocol including a vanilla constructor
(define-interface sequence-basics-face
(export sequence?
sequence-length
sequence-ref
sequence-set!
make-another-sequence))
;; things definable in terms of the basic protocol
(define-interface sequence-extras-face
(export sequence->list
sequence-tabulate!
sequence-fill!
subsequence
sequence-copy
sequence-copy!
sequence-copy/maker
sequence-append
sequence-map sequences-map
sequence-map/maker sequences-map/maker
sequence-map-into! sequences-map-into!
sequence-for-each sequences-for-each
sequence-fold sequences-fold
sequence-fold-right sequences-fold-right
sequence-null?
sequence-any sequences-any
sequence-every sequences-every
sequence= sequences=
))
;; specialised sequence operations (for lists, actually)
(define-interface sequence-specifics-face
(export list-set!
list-fill!
sublist
))
;; the sequence ADT etc.
(define-interface absequences-face
(export make-sequence-behavior
sequence-behavior?
make-absequence-record
absequence:behavior
make-absequence/behavior
absequence/behavior
list->absequence/behavior
absequence?
absequence-ref
absequence-set!
absequence-length))
;; the basic + extra sequence procedures
;; [ extends the union of SEQUENCE-BASICS- and -EXTRAS-INTERFACE with
;; `VECTOR' replacing `SEQUENCE' ]
(define-interface vector-lib-face
(export ;; constructors and the like
make-vector
vector
list->vector ; with opts
vector-tabulate
;; basics w/o the vanilla constructor
vector?
vector-length
vector-ref
vector-set!
;; extras
vector->list
vector-fill!
vector-tabulate!
subvector
vector-copy
vector-copy!
vector-append
vector-map ; forget the optional MAKER arg
vector-map-into!
vector-for-each
vector-fold
vector-fold-right
vector-null?
vector-any
vector-every
vector=
vectors-map ; but not vectors-map/maker
vectors-map-into!
vectors-for-each
vectors-fold
vectors-fold-right
vectors-any
vectors-every
vectors=
))
2003-07-27 13:36:26 -04:00
;;; refers to structures from sunterlib/s48/krims
;;; relies on implicit shadowing of exported bindings
2003-02-11 19:23:30 -05:00
;; sequences as data + behaviour
2003-02-15 19:32:31 -05:00
(define-structure absequences absequences-face
(open srfi-9+ ; define-record-type -discloser
2003-02-14 21:48:52 -05:00
krims ; assert
let-opt ; let-optionals [ from scsh ]
2003-02-11 19:23:30 -05:00
scheme)
(files uniseqs))
2003-02-13 19:47:58 -05:00
;; specialists for lists, vectors, strings
2003-02-11 19:23:30 -05:00
(define-structure sequence-specifics sequence-specifics-face
2003-03-22 17:22:15 -05:00
(open krims ; assert
srfi-1+ ; list procs
2003-02-13 19:47:58 -05:00
srfi-13 ; string procs
2003-03-22 17:22:15 -05:00
let-opt ; let-optionals [ from scsh ]
2003-07-27 13:36:26 -04:00
(modify scheme (hide map for-each member assoc) ; srfi-1+
(hide string->list string-copy string-fill!) ; srfi-13
))
2003-02-11 19:23:30 -05:00
(files specseqs))
2003-03-13 13:38:28 -05:00
2003-02-11 19:23:30 -05:00
;; basic sequence accessors etc.
(define-structure sequence-basics sequence-basics-face
(open krims ; gen-dispatch
2003-02-13 19:47:58 -05:00
let-opt ; :optional [ from scsh ]
2003-02-11 19:23:30 -05:00
sequence-specifics ; list-set! make-list
2003-02-15 19:32:31 -05:00
absequences
2003-02-11 19:23:30 -05:00
byte-vectors
2003-02-13 19:47:58 -05:00
srfi-1 ; make-list
2003-02-11 19:23:30 -05:00
srfi-23 ; error
2003-07-27 13:36:26 -04:00
(modify scheme (hide map for-each member assoc) ; srfi-1
))
2003-02-11 19:23:30 -05:00
(files baseqs))
;; sequence operations defined in terms of the basic protocol
(define-structure sequence-extras sequence-extras-face
(open sequence-basics
krims ; assert
2003-02-12 16:48:40 -05:00
util ; unspecific
2003-03-13 13:38:28 -05:00
srfi-1+ ; append! rest
2003-02-12 16:48:40 -05:00
srfi-23 ; error
2003-02-13 19:47:58 -05:00
let-opt ; let-optionals [ from scsh ]
2003-07-27 13:36:26 -04:00
(modify scheme (hide map for-each member assoc) ; srfi-1+
))
2003-02-11 19:23:30 -05:00
(files genseqs))
2003-02-13 19:47:58 -05:00
;; sequence procedures specialised to vectors
(define-structure vector-lib vector-lib-face
(open krims ; assert
util ; unspecific
let-opt ; let-optionals [ from scsh ]
2003-03-20 14:09:05 -05:00
srfi-1+ ; append! drop first rest
2003-07-27 13:36:26 -04:00
(modify scheme (hide map for-each member assoc) ; srfi-1+
))
2003-02-13 19:47:58 -05:00
;; bind the basic operations to vector specialists
(begin
(define sequence? vector?)
(define sequence-length vector-length)
(define sequence-ref vector-ref)
(define sequence-set! vector-set!)
(define (make-another-sequence v k . maybe-fill)
(apply make-vector k maybe-fill)))
2003-03-20 14:09:05 -05:00
(files genseqs ; generic code
vecnames) ; renames stuff, defines constructors
)
2003-02-13 19:47:58 -05:00
2003-02-11 19:23:30 -05:00
;; elementary and other general sequence operations, typically dispatching
;; early on the sequence type in order to make use of built-ins or special
;; code (notably for lists)
(define-structure sequence-lib (compound-interface sequence-basics-face
sequence-extras-face
2003-02-15 19:32:31 -05:00
absequences-face)
(open (with-prefix sequence-extras contiguous-)
2003-02-11 19:23:30 -05:00
sequence-basics
2003-02-15 19:32:31 -05:00
absequences
2003-02-11 19:23:30 -05:00
sequence-specifics
2003-02-13 19:47:58 -05:00
vector-lib
srfi-1 ; list procs
srfi-13 ; string procs
2003-02-15 19:32:31 -05:00
byte-vectors
2003-02-13 19:47:58 -05:00
let-opt ; let-optionals [ from scsh ]
2003-07-27 13:36:26 -04:00
(modify scheme (hide map for-each member assoc) ; srfi-1
(hide string->list string-copy string-fill!) ; srfi-13
(hide vector-fill! list->vector) ; vector-lib
))
2003-02-11 19:23:30 -05:00
(files composeqs))
2005-08-16 19:13:51 -04:00
(define-structure sequences-testbed (export )
(open sequence-lib onebol scheme))
(define-structure vectors-testbed (export )
(open vector-lib onebol scheme))