Make flvectors and fxvectors sequences.
This commit is contained in:
parent
2f469a06cd
commit
8e32e6e44c
|
@ -53,6 +53,10 @@ built-in datatypes, the sequence datatype includes the following:
|
|||
|
||||
@item{vectors (see @secref["vectors"])}
|
||||
|
||||
@item{flvectors (see @secref["flvectors"])}
|
||||
|
||||
@item{fxvectors (see @secref["fxvectors"])}
|
||||
|
||||
@item{hash tables (see @secref["hashtables"])}
|
||||
|
||||
@item{dictionaries (see @secref["dicts"])}
|
||||
|
|
|
@ -211,7 +211,7 @@
|
|||
|
||||
;; ----------------------------------------
|
||||
|
||||
;; in-flvector tests, copied from for.rktl
|
||||
;; in-fxvector tests, copied from for.rktl
|
||||
|
||||
(test-sequence [(1 2 3)] (in-fxvector (fxvector 1 2 3)))
|
||||
(test-sequence [(2 3 4)] (in-fxvector (fxvector 1 2 3 4) 1))
|
||||
|
@ -221,6 +221,10 @@
|
|||
(test-sequence [(2 4 6)] (in-fxvector (fxvector 1 2 3 4 5 6 7 8) 1 6 2))
|
||||
(test-sequence [(8 6 4)] (in-fxvector (fxvector 1 2 3 4 5 6 7 8) 7 2 -2))
|
||||
|
||||
;; fxvector sequence tests
|
||||
(test-sequence [(1 2 3)] (fxvector 1 2 3))
|
||||
(test '() 'empty-fxvector-sequence (for/list ([i (fxvector)]) i))
|
||||
|
||||
;; Check safety:
|
||||
(err/rt-test (for/fxvector ([i 5]) 8.0))
|
||||
(err/rt-test (for/fxvector #:length 5 ([i 5]) 8.0))
|
||||
|
|
|
@ -157,6 +157,11 @@
|
|||
(test-sequence [(2.0 4.0 6.0)] (in-flvector (flvector 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0) 1 6 2))
|
||||
(test-sequence [(8.0 6.0 4.0)] (in-flvector (flvector 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0) 7 2 -2))
|
||||
|
||||
;; flvector sequence tests
|
||||
|
||||
(test-sequence [(1.0 2.0 3.0)] (flvector 1.0 2.0 3.0))
|
||||
(test '() 'empty-flvector-sequence (for/list ([i (flvector)]) i))
|
||||
|
||||
;; Check safety:
|
||||
(err/rt-test (for/flvector ([i 5]) 8))
|
||||
(err/rt-test (for/flvector #:length 5 ([i 5]) 8))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"member.rkt"
|
||||
"reverse.rkt"
|
||||
'#%unsafe
|
||||
'#%flfxnum
|
||||
(for-syntax '#%kernel
|
||||
"stx.rkt"
|
||||
"qqstx.rkt"
|
||||
|
@ -459,6 +460,8 @@
|
|||
(stream? v)
|
||||
(mpair? v)
|
||||
(vector? v)
|
||||
(flvector? v)
|
||||
(fxvector? v)
|
||||
(string? v)
|
||||
(bytes? v)
|
||||
(input-port? v)
|
||||
|
@ -472,6 +475,8 @@
|
|||
[(mpair? v) (:mlist-gen v)]
|
||||
[(list? v) (:list-gen v)]
|
||||
[(vector? v) (:vector-gen v 0 (vector-length v) 1)]
|
||||
[(flvector? v) (:flvector-gen v 0 (flvector-length v) 1)]
|
||||
[(fxvector? v) (:fxvector-gen v 0 (fxvector-length v) 1)]
|
||||
[(string? v) (:string-gen v 0 (string-length v) 1)]
|
||||
[(bytes? v) (:bytes-gen v 0 (bytes-length v) 1)]
|
||||
[(input-port? v) (:input-port-gen v)]
|
||||
|
@ -876,6 +881,11 @@
|
|||
#'in-bytes
|
||||
#'bytes-ref))
|
||||
|
||||
(define-:vector-like-gen :flvector-gen unsafe-flvector-ref)
|
||||
;; in-flvector is defined in racket/flonum
|
||||
(define-:vector-like-gen :fxvector-gen unsafe-fxvector-ref)
|
||||
;; in-fxvector is defined in racket/fixnum
|
||||
|
||||
;; ------------------------------------------------------------------------
|
||||
|
||||
(define (stop-before g pred)
|
||||
|
|
Loading…
Reference in New Issue
Block a user