Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Ackermann-function/TXR/ackermann-function.txr
Normal file
22
Task/Ackermann-function/TXR/ackermann-function.txr
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(defmacro defmemofun (name (. args) . body)
|
||||
(let ((hash (gensym "hash-"))
|
||||
(argl (gensym "args-"))
|
||||
(hent (gensym "hent-"))
|
||||
(uniq (copy-str "uniq")))
|
||||
^(let ((,hash (hash :equal-based)))
|
||||
(defun ,name (,*args)
|
||||
(let* ((,argl (list ,*args))
|
||||
(,hent (inhash ,hash ,argl ,uniq)))
|
||||
(if (eq (cdr ,hent) ,uniq)
|
||||
(set (cdr ,hent) (block ,name (progn ,*body)))
|
||||
(cdr ,hent)))))))
|
||||
|
||||
(defmemofun ack (m n)
|
||||
(cond
|
||||
((= m 0) (+ n 1))
|
||||
((= n 0) (ack (- m 1) 1))
|
||||
(t (ack (- m 1) (ack m (- n 1))))))
|
||||
|
||||
(each ((i (range 0 3)))
|
||||
(each ((j (range 0 4)))
|
||||
(format t "ack(~a, ~a) = ~a\n" i j (ack i j))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue