Changeset 21662 in project
 Timestamp:
 11/25/10 21:00:08 (9 years ago)
 Location:
 release/4/quaternions/trunk
 Files:

 3 added
 1 edited
 1 moved
Legend:
 Unmodified
 Added
 Removed

release/4/quaternions/trunk/quaternions.scm
r21628 r21662 47 47 48 48 (import chicken 49 (except scheme 49 (except scheme ; except for those that are redefined 50 50 makerectangular 51 51 makepolar 52 realpart 52 53 imagpart 53 54 magnitude … … 70 71 atan 71 72 ) 72 ) ; chicken extras scheme) 73 (only extras fprintf) 74 ) 73 75 74 76 (requireextension numbers) … … 91 93 (definerecordtype :quaternion 92 94 (makequaternion w x y z) 93 q uaternion?95 qquaternion? 94 96 (w quaternionw) 95 97 (x quaternionx) 96 98 (y quaterniony) 97 99 (z quaternionz)) 100 101 (definerecordprinter (:quaternion q out) 102 (fprintf out "~A~A~Ai~A~Aj~A~Ak" 103 (quaternionw q) 104 (if (positive? (quaternionx q)) "+" "") 105 (quaternionx q) 106 (if (positive? (quaterniony q)) "+" "") 107 (quaterniony q) 108 (if (positive? (quaternionz q)) "+" "") 109 (quaternionz q))) 98 110 99 111 ;makerectangular returns a plain real or … … 192 204 (lambda (q) 193 205 (or (complex? q) 194 (q uaternion? q))))206 (qquaternion? q)))) 195 207 196 208 ;in the quaternion language, quaternion? 197 209 ;should return #t for all numbers, not just 198 210 ;the quaternion structs 199 (define q quaternion? number?)211 (define quaternion? number?) 200 212 201 213 (define = 
release/4/quaternions/trunk/tests/run.scm
r21628 r21662 1 (load "quaternions.scm") 2 (import quaternions) 3 1 (requireextension quaternions) 4 2 (requireextension srfi78) 5 3 … … 16 14 (check (number? q2) => #t) 17 15 (check (number? q3) => #t) 18 (check (quaternion? q1) => # f)19 (check (quaternion? q2) => # f)16 (check (quaternion? q1) => #t) 17 (check (quaternion? q2) => #t) 20 18 (check (quaternion? q3) => #t) 21 19 (check (realpart q1) => 0)
Note: See TracChangeset
for help on using the changeset viewer.