Changeset 37269 in project
 Timestamp:
 02/21/19 08:17:09 (8 months ago)
 Location:
 release/5/srfi4comprehensions/trunk
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

release/5/srfi4comprehensions/trunk/srfi4comprehensions.egg
r37268 r37269 5 5 (license "SRFI") 6 6 (dependencies srfi42) 7 (testdependencies srfi1 test) 7 8 (category data) 8 9 (author "Will Farr") 
release/5/srfi4comprehensions/trunk/srfi4comprehensions.scm
r37268 r37269 33 33 (module srfi4comprehensions 34 34 (:s8vector :u8vector :s16vector :u16vector :s32vector 35 :u32vector :f64vector :f32vector 36 :s64vector :u64vector 35 :u32vector :f64vector :f32vector :s64vector :u64vector 37 36 38 37 s8vectorec u8vectorec s16vectorec u16vectorec s32vectorec 39 u32vectorec f64vectorec f32vectorec38 u32vectorec s64vectorec u64vectorec f64vectorec f32vectorec 40 39 41 40 s8vectoroflengthec u8vectoroflengthec s16vectoroflengthec 42 u16vectoroflengthec s32vectoroflengthec 43 u32vectoroflengthec41 u16vectoroflengthec s32vectoroflengthec u32vectoroflengthec 42 s64vectoroflengthec u64vectoroflengthec 44 43 f64vectoroflengthec f32vectoroflengthec) 45 44 
release/5/srfi4comprehensions/trunk/tests/run.scm
r37268 r37269 1 (import scheme (chicken base) srfi 42 srfi4comprehensions)1 (import scheme (chicken base) srfi1 srfi4 srfi42 srfi4comprehensions test) 2 2 3 (define n 19)3 (define n 20) 4 4 5 ( print (s32vectorec (: i 0 (+ 1 n)) i))5 (define xlst (listtabulate n (lambda (x) x))) 6 6 7 (print (f32vectorec (: i 0. (+ 1 n)) (* 0.1 i))) 7 (define (to4dp f) 8 (/ (round (* f 10000)) 10000)) 9 10 (define (=4 n1 n2) 11 (= (to4dp n1) (to4dp n2))) 12 13 (testgroup "SRFI4 vector comprehension" 14 15 (test (list>f64vector xlst) (f64vectorec (: i 0 n) i) ) 16 (test (list>f32vector xlst) (f32vectorec (: i 0 n) i) ) 17 ; (test (list>s64vector xlst) (s64vectorec (: i 0 n) i) ) 18 (test (list>u64vector xlst) (u64vectorec (: i 0 n) i) ) 19 (test (list>s32vector xlst) (s32vectorec (: i 0 n) i) ) 20 (test (list>u32vector xlst) (u32vectorec (: i 0 n) i) ) 21 (test (list>s16vector xlst) (s16vectorec (: i 0 n) i) ) 22 (test (list>u16vector xlst) (u16vectorec (: i 0 n) i) ) 23 (test (list>s8vector xlst) (s8vectorec (: i 0 n) i) ) 24 (test (list>u8vector xlst) (u8vectorec (: i 0 n) i) ) 25 26 ) 8 27 9 28 10 (let ((v (f64vectorec (: i 0. (+ 1 n)) (* 0.5 i)))) 11 (print v) 12 (print (foldec 0. (:f64vector x (index i) v) x (lambda (x ax) (+ ax (* x x))))) 13 ) 29 30 (testgroup "SRFI4 vector fold comprehension" 31 32 (let ((v (f64vectorec (: i 0. n) (* 0.5 i)))) 33 34 (testassert (=4 617.5 (foldec 0. (:f64vector x (index i) v) x (lambda (x ax) (+ ax (* x x))))))) 35 36 (let ((v (f32vectorec (: i 0. n) (* 0.5 i)))) 37 38 (testassert (=4 617.5 (foldec 0. (:f32vector x (index i) v) x (lambda (x ax) (+ ax (* x x)))))) 39 40 ))
Note: See TracChangeset
for help on using the changeset viewer.