Even

From mojo_puzzler
Revision as of 15:55, 17 November 2023 by Gneale (talk | contribs) (Created page with "===== 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 (...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 ()