(load "../common") ;; "it" is (+ 2 2) (test (ifa (> (+ 2 2) 0) (* it 2)) 8) ;; "it" is (* x x) (test (let ((x 7)) (ifa (>= (* x x) 49) (isqrt it))) 7) ;; no it-candidates: "it" is leftmost arg x. (test (let ((x 1) (y 0)) (ifa (> x y) it)) 1) ;; multiple it-candidates: error (test (let (x y) (ifa (> (* x x) (* y y)) it)) :error) ;; "it" is (+ 3 (* 2 x)) (test (let ((x 5)) (ifa (< 0 (+ 3 (* 2 x)) 20) (* 100 it))) 1300) ;; "it" is (length '(a b c d)) ;; Intuition: it" could also be '(a b c d) ;; TODO: deal specially with chains of unary functions. ;; How about it = (length ...), itt = '(a b c d) (test (ifa (not (oddp (length '(a b c d)))) it) 4) ;; "it" is y because %x% is constantp (test (symacrolet ((%x% 42)) (let ((y 41)) (ifa (> %x% y) it))) 42) (test (let ((x 5)) (conda ((not (integerp x)) (list it)) ((oddp (+ 2 x)) (list it)))) (7)) (test (let ((l (list 1 2 3))) (ifa (evenp (second l)) (inc it)) l) (1 3 3)) (test (let ((l (list 1 2 3 4 5))) (conda ((< 2 (third l) 4) (inc it))) l) (1 2 4 4 5)) (test (let* ((x 2) (y 4) (l (list 1 2 3 4 5))) (conda ((< x (third l) y) (inc it))) l) (1 2 4 4 5))