<commit_before>;; Common Lisp Script
;; <NAME>

;; LAZY PROGRAMMING

;; PROG: Creating the Lazy and Force Commands
;; NOTE: This chapter has a lazy evaluation system very similar
;;       to discussed on the lectures about STREAMS (6A-6B) of SICP at MIT.

(defmacro lazy (&body body)
  (let ((forced (gensym))
        (value (gensym)))
    `(let ((,forced nil)
           (,value nil))
       (lambda ()
         (unless ,forced
           (setf ,value (progn ,@body))
           (setf ,forced t))
         ,value))))<commit_msg>Add defpackage definition for lazy package cap18-lazy-programming<commit_after>;; Common Lisp Script
;; <NAME>

;; LAZY PROGRAMMING

;; PROG: Creating the Lazy and Force Commands
;; NOTE: This chapter has a lazy evaluation system very similar
;;       to discussed on the lectures about STREAMS (6A-6B) of SICP at MIT.

(defpackage :lazy
  (:use :cl)
  (:export :lazy
           :force
           :lazy-cons
           :lazy-car
           :lazy-cdr
           :lazy-nil
           :lazy-null
           :make-lazy
           :take
           :take-all
           :lazy-mapcar
           :lazy-mapcan
           :lazy-find-if
           :lazy-nth
           :*integers*))

(in-package :lazy)

(defmacro lazy (&body body)
  (let ((forced (gensym))
        (value (gensym)))
    `(let ((,forced nil)
           (,value nil))
       (lambda ()
         (unless ,forced
           (setf ,value (progn ,@body))
           (setf ,forced t))
         ,value))))
{'fraction_non_alphanumeric': 0.12339851652056642, 'fraction_numerical': 0.004045853000674309, 'mean_word_length': 1.956175298804781, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '810146', 'n_tokens_mistral': 488, 'n_tokens_neox': 472, 'n_words': 149}