Iterate

From mojo_puzzler
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Return to: Chialisp
Return to: Recursive Functions

Example 1

(mod (n)
(defun iterate (n)
 (if (= n 0)
     n
   (list n (iterate (- n 1)))
   )
 )
(iterate n)
)

Example 1 usage:

brun '(a (q 2 2 (c 2 (c 5 ()))) (c (q 2 (i (= 5 ()) (q . 5) (q 4 5 (c (a 2 (c 2 (c (- 5 (q . 1)) ()))) ()))) 1) 1))' '(50)'

(50 (49 (48 (47 (46 (45 (44 (43 (42 (41 (40 (39 (38 (37 (softfork (35 (all (any (not (31 (pubkey_for_exp (point_add (28 (lognot (logxor (logior (logand (lsh (ash (> (divmod (/ (* (- (+ (15 (concat (strlen (substr (sha256 (>s (= (x (l (r (f (c (i (a (q ())))))))))))))))))))))))))))))))))))))))))))))))))

Example 2

(mod (index)
  (defun iterate (index)
      (if (= index 0)
      (1)
      (list (list 51 0xdeadbeef index) (iterate (- index 1)))
       )
   )
(iterate index)
)

Example 2 usage:

brun '(a (q 2 2 (c 2 (c 5 ()))) (c (q 2 (i (= 5 ()) () (q 4 (c (q . 51) (c (q . 0xdeadbeef) (c 5 ()))) (c (a 2 (c 2 (c (- 5 (q . 1)) ()))) ()))) 1) 1))' '(10)'

((51 0xdeadbeef 10) ((51 0xdeadbeef 9) ((51 0xdeadbeef 8) ((51 0xdeadbeef 7) ((51 0xdeadbeef 6) ((51 0xdeadbeef 5) ((51 0xdeadbeef 4) ((51 0xdeadbeef 3) ((51 0xdeadbeef 2) ((51 0xdeadbeef 1) ()))))))))))