<commit_before>;;; PAPPLY
;;; papply.lisp
;;; main implementation.
;;; Author: chiku (<NAME> <EMAIL>)
;;; License: MIT License
(in-package :papply)

(eval-when (:compile-toplevel :execute)
  #+sbcl (require :sb-cltl2))

(eval-when (:load-toplevel :compile-toplevel :execute)
  (defun underscore-included-p (tree)
    (cond ((symbolp tree) (eq '_ tree))
          ((atom tree) nil)
          (t (some #'underscore-included-p tree))))

  (defun count-underscore (tree)
    (let ((c 0))
      (with-tree-leaves tree (eq leaf '_) (incf c))
      c))

  (defun lexically-bound-p (name env)
    (or
      #+sbcl (sb-cltl2:variable-information name env)
      nil)))

(defun construct-body (op not-applied-args body env)
  (if (and (symbolp op) (not (lexically-bound-p op env)))
    (if (or (macro-function op) (special-operator-p op))
      `(,op ,@body)
      `(apply #',op ,@body ,not-applied-args))
    `(apply ,op ,@body ,not-applied-args)))

(defmacro papply-enumerate-format (op &rest args &environment env)
  (let* ((gensym-lst)
         (body (with-tree-leaves args (eq leaf '_)
                 (car (push (gensym "PARG") gensym-lst)))))
    (with-gensyms (not-applied-args)
      `(lambda (,@(nreverse gensym-lst) &rest ,not-applied-args)
         (declare (ignorable ,not-applied-args))
         ,(construct-body op not-applied-args body env)))))

(defmacro papply-enumerate-format (op &rest args &environment env)
  (let* ((gensym-lst)
         (body (with-tree-leaves args (eq leaf '_)
                 (car (push (gensym "PARG") gensym-lst)))))
    (with-gensyms (not-applied-args)
      `(lambda (,@(nreverse gensym-lst) &rest ,not-applied-args)
         (apply
           ,(if (and (symbolp op) (not (lexically-bound-p op env)))
              `#',op
              op)
           ,@body ,not-applied-args)))))
<commit_msg>[Tiny] Old code is removed.<commit_after>;;; PAPPLY
;;; papply.lisp
;;; main implementation.
;;; Author: chiku (<NAME> <EMAIL>)
;;; License: MIT License
(in-package :papply)

(eval-when (:compile-toplevel :execute)
  #+sbcl (require :sb-cltl2))

(eval-when (:load-toplevel :compile-toplevel :execute)
  (defun underscore-included-p (tree)
    (cond ((symbolp tree) (eq '_ tree))
          ((atom tree) nil)
          (t (some #'underscore-included-p tree))))

  (defun count-underscore (tree)
    (let ((c 0))
      (with-tree-leaves tree (eq leaf '_) (incf c))
      c))

  (defun lexically-bound-p (name env)
    (or
      #+sbcl (sb-cltl2:variable-information name env)
      nil)))

(defun construct-body (op not-applied-args body env)
  (if (and (symbolp op) (not (lexically-bound-p op env)))
    (if (or (macro-function op) (special-operator-p op))
      `(,op ,@body)
      `(apply #',op ,@body ,not-applied-args))
    `(apply ,op ,@body ,not-applied-args)))

(defmacro papply-enumerate-format (op &rest args &environment env)
  (let* ((gensym-lst)
         (body (with-tree-leaves args (eq leaf '_)
                 (car (push (gensym "PARG") gensym-lst)))))
    (with-gensyms (not-applied-args)
      `(lambda (,@(nreverse gensym-lst) &rest ,not-applied-args)
         (declare (ignorable ,not-applied-args))
         ,(construct-body op not-applied-args body env)))))

{'fraction_non_alphanumeric': 0.1763789342474291, 'fraction_numerical': 0.001869741352446245, 'mean_word_length': 2.9146341463414633, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1139355', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1151, 'n_words': 295}