<commit_before>;;;; rep-theatre.lisp

(in-package #:rep-theatre)

(defmacro are (test &rest tests)
  "Evaluate a list of tests with is"
  `(progn
     (stefil:is ,test)
     (unless (null ',tests)
       (are ,@tests))))

;; Adapted from <NAME>'s find-maximizing-item
;; http://groups.google.com/group/comp.lang.lisp/msg/dd7435a500d3d434?dmode=source
;; <2<EMAIL>-<EMAIL>>
(defun most (sequence &key (key #'identity) (test #'>))
  "Return item,value,position of the item of the list with the maximum
`key' value, ordered by `test'. In the case of multiple items having
the same value, the largest index is returned. one towards the end of
the list is returned."
  (loop for item in sequence
     for value = (funcall key item)
     for position from 0
     for current-triplet = (list item value position)
     as max-triplet = current-triplet
     then (if (funcall test (second current-triplet) (second max-triplet))
              current-triplet
              max-triplet)
     collecting current-triplet into p
     finally (return (values-list max-triplet))))<commit_msg>fixed for sbcl, which didn't like compiling (are)<commit_after>;;;; rep-theatre.lisp

(in-package #:rep-theatre)

(defmacro are (&rest tests)
  "Evaluate a list of tests with is."
  `(let ((result (gensym "result"))
         (test (gensym)))
     (loop :for test :in ',tests
        do (setf result (stefil:is test)))
     result))

;; Adapted from <NAME>'s find-maximizing-item
;; http://groups.google.com/group/comp.lang.lisp/msg/dd7435a500d3d434?dmode=source
;; <<EMAIL>-<EMAIL>>
(defun most (sequence &key (key #'identity) (test #'>))
  "Return item,value,position of the item of the list with the maximum
`key' value, ordered by `test'. In the case of multiple items having
the same value, the largest index is returned. one towards the end of
the list is returned."
  (loop for item in sequence
     for value = (funcall key item)
     for position from 0
     for current-triplet = (list item value position)
     as max-triplet = current-triplet
     then (if (funcall test (second current-triplet) (second max-triplet))
              current-triplet
              max-triplet)
     collecting current-triplet into p
     finally (return (values-list max-triplet))))
{'fraction_non_alphanumeric': 0.12, 'fraction_numerical': 0.011111111111111112, 'mean_word_length': 3.353965183752418, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '6491342', 'n_tokens_mistral': 729, 'n_tokens_neox': 704, 'n_words': 250}