Volkan YAZICI wrote:
Merhaba,

IBM developerWorks'te gördüğüm bir makalenin liste üyelerinin ilgisini
çekebileceğini düşündüm:

  Lazy programming and lazy evaluation
  [http://www-128.ibm.com/developerworks/linux/library/l-lazyprog.html]
  Lazy programming is a general concept of delaying the processing of a
  function or request until the results are needed. This concept has
  numerous applications, from the obvious to the obscure. Thinking in
  terms of lazy programming can help you rid your code of unneeded
  computation and restructure programs to be more problem-oriented.

(in-package :cl-user)

(defparameter unforced (gensym))

(defstruct delay forced closure)

(defmacro delay (expr)
 (let ((self (gensym)))
   `(let ((,self (make-delay :forced unforced)))
      (setf (delay-closure ,self)
            #'(lambda ()
                (setf (delay-forced ,self) ,expr)))
      ,self)))

(defun force (x)
 (if (delay-p x)
     (if (eq (delay-forced x) unforced)
         (funcall (delay-closure x))
         (delay-forced x))
     x))

(let ((x 2))
 (setq d (delay (1+ x))))

CL-USER> (force d)
3

Sevgiler...

--
Aycan iRiCAN
C0R3 Computer Security Group
http://people.core.gen.tr/~aycan.irican/


_______________________________________________
cs-lisp mailing list
cs-lisp@cs.bilgi.edu.tr
http://church.cs.bilgi.edu.tr/lcg
http://cs.bilgi.edu.tr/mailman/listinfo/cs-lisp

Cevap