Changeset 21662 in project


Ignore:
Timestamp:
11/25/10 21:00:08 (9 years ago)
Author:
petercrlane
Message:

installable version

Location:
release/4/quaternions/trunk
Files:
3 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • release/4/quaternions/trunk/quaternions.scm

    r21628 r21662  
    4747
    4848  (import chicken
    49           (except scheme
     49          (except scheme ; except for those that are redefined
    5050                  make-rectangular
    5151                  make-polar
     52                  real-part
    5253                  imag-part
    5354                  magnitude
     
    7071                  atan
    7172                  )
    72           ) ; chicken extras scheme)
     73          (only extras fprintf)
     74          )
    7375
    7476  (require-extension numbers)
     
    9193  (define-record-type :quaternion
    9294                      (make-quaternion w x y z)
    93                       quaternion?
     95                      q-quaternion?
    9496                      (w quaternion-w)
    9597                      (x quaternion-x)
    9698                      (y quaternion-y)
    9799                      (z quaternion-z))
     100
     101  (define-record-printer (:quaternion q out)
     102                         (fprintf out "~A~A~Ai~A~Aj~A~Ak"
     103                                  (quaternion-w q)
     104                                  (if (positive? (quaternion-x q)) "+" "")
     105                                  (quaternion-x q)
     106                                  (if (positive? (quaternion-y q)) "+" "")
     107                                  (quaternion-y q)
     108                                  (if (positive? (quaternion-z q)) "+" "")
     109                                  (quaternion-z q)))
    98110
    99111  ;make-rectangular returns a plain real or
     
    192204    (lambda (q)
    193205      (or (complex? q)
    194           (quaternion? q))))
     206          (q-quaternion? q))))
    195207
    196208  ;in the quaternion language, quaternion?
    197209  ;should return #t for all numbers, not just
    198210  ;the quaternion structs
    199   (define q-quaternion? number?)
     211  (define quaternion? number?)
    200212
    201213  (define =
  • release/4/quaternions/trunk/tests/run.scm

    r21628 r21662  
    1 (load "quaternions.scm")
    2 (import quaternions)
    3 
     1(require-extension quaternions)
    42(require-extension srfi-78)
    53
     
    1614  (check (number? q2) => #t)
    1715  (check (number? q3) => #t)
    18   (check (quaternion? q1) => #f)
    19   (check (quaternion? q2) => #f)
     16  (check (quaternion? q1) => #t)
     17  (check (quaternion? q2) => #t)
    2018  (check (quaternion? q3) => #t)
    2119  (check (real-part q1) => 0)
Note: See TracChangeset for help on using the changeset viewer.