<commit_before>(ns sicp.chapter3.5-2)

;;;; 3.5  Streams

;;; 3.5.2  Infinite Streams

;; Exercise 3.53
(def s (lazy-seq (cons 1 (map + s s))))

;; Exercise 3.54
(defn mul-streams [s1 s2]
  (map * s1 s2))

(def integers (rest (range)))

(def factorials
  (lazy-seq (cons 1 (mul-streams (rest integers) factorials))))
<commit_msg>Improve Exercise 3.53 implementation<commit_after>(ns sicp.chapter3.5-2)

;;;; 3.5  Streams

;;; 3.5.2  Infinite Streams

;; Exercise 3.53
(defn add-streams [s1 s2]
  (map + s1 s2))

(def s (lazy-seq (cons 1 (add-streams s s))))

#_(take 10 s)

;; Exercise 3.54
(defn mul-streams [s1 s2]
  (map * s1 s2))

(def integers (rest (range)))

(def factorials
  (lazy-seq (cons 1 (mul-streams (rest integers) factorials))))

#_(take 10 factorials)

{'fraction_non_alphanumeric': 0.17532467532467533, 'fraction_numerical': 0.06623376623376623, 'mean_word_length': 3.7300613496932513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2328678', 'n_tokens_mistral': 363, 'n_tokens_neox': 326, 'n_words': 94}