Even

From mojo_puzzler
Jump to navigation Jump to search
Return to: Chialisp
Return to: Additional Functions
(mod (num)
    (defun remainder (x y)
     (r (divmod x y)))
     (defun even (num)
       (if (= (remainder num 2) 0)
       (q . even)
       (x)))
(even num)
     )

Example Usage

brun '(a (q 2 4 (c 2 (c 5 ()))) (c (q (a (i (= (a 6 (c 2 (c 5 (q 2)))) ()) (q 1 . "even") (q 8)) 1) 6 (divmod 5 11)) 1))' '(10)'

"even"

brun '(a (q 2 4 (c 2 (c 5 ()))) (c (q (a (i (= (a 6 (c 2 (c 5 (q 2)))) ()) (q 1 . "even") (q 8)) 1) 6 (divmod 5 11)) 1))' '(11)'

FAIL: clvm raise ()