Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,23 +1,22 @@
|
|||
@(do
|
||||
(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)))))))
|
||||
(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))))))
|
||||
(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)))))
|
||||
(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