<commit_before>; PI Common LISP example.

; Abstract getting command line arguments.
; In sbcl the interpreter is an extra argument.

; For CLISP: clisp pi.cl <n>
; For SBCL: sbcl --script pi.cl <n>
; For GCL: gcl -f pi.cl <n>
; For ECL: ecl -shell pi.cl <n>

(defun getargs ()
  (or
   #+CLISP *args*
   #+SBCL (cdr *posix-argv*)
   #+GCL (cdr si::*command-args*)
   #+ECL (cdr(cdr(cdr si::*command-args*)))
   nil))

(defun range (b n j) 
  (if (>= b n)
    '()
    (cons b (range (+ b j) n j))
  )
)


(defun pc (c) (/ (apply #'+ (map 'list #'(lambda (x) (/ 4 (+ 1 (* x x))))((lambda (n) (range (/ 0.5 n) 1 (/ 1 n))) c))) c))

(defvar n 5000000)<commit_msg>Loop range to decrease stack usage.<commit_after>; PI Common LISP example.

; Abstract getting command line arguments.
; In sbcl the interpreter is an extra argument.

; For CLISP: clisp pi.cl <n>
; For SBCL: sbcl --script pi.cl <n>
; For GCL: gcl -f pi.cl <n>
; For ECL: ecl -shell pi.cl <n>

(defun getargs ()
  (or
   #+CLISP *args*
   #+SBCL (cdr *posix-argv*)
   #+GCL (cdr si::*command-args*)
   #+ECL (cdr(cdr(cdr si::*command-args*)))
   nil))

(defun range (b n j) 
  (loop while (< b n) 
    do (setf b (+ b j)) 
    collect (- b j)
  )
)


(defun pc (c) (/ (apply #'+ (map 'list #'(lambda (x) (/ 4 (+ 1 (* x x))))((lambda (n) (range (/ 0.5 n) 1 (/ 1 n))) c))) c))

(defvar n 5000000)
{'fraction_non_alphanumeric': 0.2038404726735598, 'fraction_numerical': 0.019202363367799114, 'mean_word_length': 2.8714285714285714, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '1322624', 'n_tokens_mistral': 617, 'n_tokens_neox': 568, 'n_words': 196}