we testing sucessfull again
This commit is contained in:
+14
-14
@@ -1,6 +1,6 @@
|
||||
(import "oo.slime")
|
||||
|
||||
(define-class vector3 (x y z)
|
||||
(define-class (vector3 x y z)
|
||||
(define (get-x) x)
|
||||
(define (get-y) y)
|
||||
(define (get-z) z)
|
||||
@@ -20,26 +20,26 @@
|
||||
|
||||
(define (add other)
|
||||
(make-vector3
|
||||
(+ x (other get-x))
|
||||
(+ y (other get-y))
|
||||
(+ z (other get-z))))
|
||||
(+ x (other 'get-x))
|
||||
(+ y (other 'get-y))
|
||||
(+ z (other 'get-z))))
|
||||
|
||||
(define (subtract other)
|
||||
(make-vector3
|
||||
(- x (other get-x))
|
||||
(- y (other get-y))
|
||||
(- z (other get-z))))
|
||||
(- x (other 'get-x))
|
||||
(- y (other 'get-y))
|
||||
(- z (other 'get-z))))
|
||||
|
||||
(define (scalar-product other)
|
||||
(+ (* x (other get-x))
|
||||
(* y (other get-y))
|
||||
(* z (other get-z))))
|
||||
(+ (* x (other 'get-x))
|
||||
(* y (other 'get-y))
|
||||
(* z (other 'get-z))))
|
||||
|
||||
(define (cross-product other)
|
||||
(make-vector3
|
||||
(- (* y (other get-z)) (* z (other get-y)))
|
||||
(- (* z (other get-x)) (* x (other get-z)))
|
||||
(- (* x (other get-y)) (* y (other get-x)))))
|
||||
(- (* y (other 'get-z)) (* z (other 'get-y)))
|
||||
(- (* z (other 'get-x)) (* x (other 'get-z)))
|
||||
(- (* x (other 'get-y)) (* y (other 'get-x)))))
|
||||
|
||||
(define (print)
|
||||
(printf :sep "" "[vector3] (" x y z ")"))
|
||||
@@ -49,4 +49,4 @@
|
||||
(define v2 (make-vector3 3 2 1))
|
||||
|
||||
(assert (= (type v1) (type v2) :vector3))
|
||||
(assert (= (v1 scalar-product v2) 10))
|
||||
(assert (= (v1 'scalar-product v2) 10))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(import "oo.slime")
|
||||
|
||||
(define-class vector3 (x y z) (define (get-x) x) (define (get-y) y) (define (get-z) z) (define (set-x new-x) (mutate x new-x)) (define (set-y new-y) (mutate y new-y)) (define (set-z new-z) (mutate z new-z)) (define (length) (** (+ (* x x) (* y y) (* z z)) 0.500000)) (define (scale fac) (mutate x (* fac x)) (mutate y (* fac y)) (mutate z (* fac z)) fac) (define (add other) (make-vector3 (+ x (other get-x)) (+ y (other get-y)) (+ z (other get-z)))) (define (subtract other) (make-vector3 (- x (other get-x)) (- y (other get-y)) (- z (other get-z)))) (define (scalar-product other) (+ (* x (other get-x)) (* y (other get-y)) (* z (other get-z)))) (define (cross-product other) (make-vector3 (- (* y (other get-z)) (* z (other get-y))) (- (* z (other get-x)) (* x (other get-z))) (- (* x (other get-y)) (* y (other get-x))))) (define (print) (printf :sep "" "[vector3] (" x y z ")")))
|
||||
(define-class (vector3 x y z) (define (get-x) x) (define (get-y) y) (define (get-z) z) (define (set-x new-x) (mutate x new-x)) (define (set-y new-y) (mutate y new-y)) (define (set-z new-z) (mutate z new-z)) (define (length) (** (+ (* x x) (* y y) (* z z)) 0.500000)) (define (scale fac) (mutate x (* fac x)) (mutate y (* fac y)) (mutate z (* fac z)) fac) (define (add other) (make-vector3 (+ x (other 'get-x)) (+ y (other 'get-y)) (+ z (other 'get-z)))) (define (subtract other) (make-vector3 (- x (other 'get-x)) (- y (other 'get-y)) (- z (other 'get-z)))) (define (scalar-product other) (+ (* x (other 'get-x)) (* y (other 'get-y)) (* z (other 'get-z)))) (define (cross-product other) (make-vector3 (- (* y (other 'get-z)) (* z (other 'get-y))) (- (* z (other 'get-x)) (* x (other 'get-z))) (- (* x (other 'get-y)) (* y (other 'get-x))))) (define (print) (printf :sep "" "[vector3] (" x y z ")")))
|
||||
|
||||
(define v1 (make-vector3 1 2 3))
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
|
||||
(assert (= (type v1) (type v2) :vector3))
|
||||
|
||||
(assert (= (v1 scalar-product v2) 10))
|
||||
(assert (= (v1 'scalar-product v2) 10))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(define (make-counter) ((lambda (var) (lambda () (mutate var (+ 1 var)) var)) 0))
|
||||
(define (make-counter) (let ((var 0)) (lambda () (mutate var (+ 1 var)) var)))
|
||||
|
||||
(define counter1 (make-counter))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user