<commit_before>;; https://projecteuler.net/problem=7
;; The 10,001st prime number.
;; TODO this lazy-list code is clumsy

(define (euler7 n)
  ((primes) n))

(define (primes)
  (cons/lazy 2 (given () (filter-prime (odd-integers 3)))))

(define (odd-integers n)
  (cons/lazy n (given () (odd-integers (+ n 2)))))

(define (filter-prime ns) 
  (let p ns.first)
  (cons/lazy p (given ()
                 (filter-prime
                  (filter/lazy (given (k) (not= 0 (k .remainder p)))
                               ns.rest)))))

;(print (euler7 5))
(print (euler7 100))
;(print (euler7 10000))
;; TODO implement the real sieve
<commit_msg>tweak<commit_after>;; https://projecteuler.net/problem=7
;; The 10,001st prime number.
;; TODO this lazy-list code is clumsy

(define (euler7 n)
  ((primes) n))

(define (primes)
  (cons/lazy 2 (given () (filter-prime (odd-integers 3)))))

(define (odd-integers n)
  (cons/lazy n (given () (odd-integers (+ n 2)))))

(define (filter-prime ns) 
  (let p ns.first)
  (cons/lazy p (given ()
                 (filter-prime
                  (for filter/lazy ((k ns.rest))
                    (not= 0 (k .remainder p)))))))

;(print (euler7 5))
(print (euler7 100))
;(print (euler7 10000))
;; TODO implement the real sieve

{'fraction_non_alphanumeric': 0.17342879872712808, 'fraction_numerical': 0.03659506762132061, 'mean_word_length': 2.7, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6221406', 'n_tokens_mistral': 507, 'n_tokens_neox': 456, 'n_words': 134}