self-modifying version:
Code: Select all
(setf rotating-tasklet^ (fn (loc body)
(rotate body)
(letex (loc loc body body)
(expand (setf loc (fn (arg)
(pop loc -1)
(push (first (rotate 'body -1)) loc -1)
'first-of-body-goes-here))))))
Code: Select all
(setf rotating-tasklet^ (fn (loc body)
(rotate body)
(letex (loc loc body body)
(expand (setf loc (fn (arg)
(eval (first (rotate 'body -1)))))))))
Code: Select all
(rotating-tasklet^ 'rot
'((+ 10 arg)
(+ 11 arg)
(+ 12 arg)))
(rotating-tasklet^ 'rotX
'((println "first")
(println "second")
(println "third")))
(rotX)
(println (rot 1000))
(rotX)
(println (rot 2500))
(rotX)
(println (rot 333))
slightly shorter no eval version using setf instead of pop/push
Code: Select all
(setf rotating-tasklet^ (fn (loc body)
(rotate body)
(letex (loc loc body body)
(expand (setf loc (fn (arg)
(setf (last loc) (first (rotate 'body -1)))
'first-of-body-goes-here))))))
EDIT: incorporated setf into all patterns.