2 1)
4)))
+(deftest test-tfassoc
+ (is (= (mt/tfassoc 2 '[] #(* % 3))
+ 6))
+ (is (= (mt/tfassoc '[up 0 [up 1 2] [down 3 4]]
+ '[2 1]
+ #(+ % 4))
+ '[up 0 [up 1 2] [down 3 8]]
+ )))
+
(deftest test-t+2
(is (= (mt/t+2 1 2) 3))
(is (= (mt/t+2 '[up 1 2 3]
'[up 16 22]
)))
-(deftest test-jaco
- (binding [mt/*dxi* 0.5]
- (is (= (mt/jaco (fn [[x y]]
- [(* 2 x y)
- (+ (* 5 x) (* 3 y))
- ])
- [1 2])
- [[4 2] [5 3]]))))
+(deftest test-partial-val
+ (is (= (binding [mt/*dx* 0.5]
+ (mt/partial-val (fn [x] (* 4 x))
+ []
+ 3
+ ))
+ 4
+ ))
+ (is (= (binding [mt/*dx* 0.5]
+ (mt/partial-val (fn [[_ x y]]
+ ['up
+ (* 2 x y)
+ (+ (* 5 x) (* 3 y))
+ ])
+ [0]
+ ['up 1 2]
+ ))
+ ['up 4 5]
+ ))
+ (is (= (binding [mt/*dx* 0.5]
+ (mt/partial-val (fn [[_ x y]]
+ ['up
+ (* 2 x y)
+ (+ (* 5 x) (* 3 y))
+ ])
+ []
+ ['up 1 2]
+ ))
+ ['down ['up 4 5]
+ ['up 2 3]
+ ])))
(run-tests)