<commit_before>(ns active.clojure.lens
  "Lenses should obey the following laws:

  GetPut, or YankShove:

      (= (yank (shove data my-lens val)
               my-lens)
         val)

  Meaning: you get back what you put in.

  PutGet, or ShoveYank:

      (= (shove data
                my-lens
                (yank data my-lens))
         data)

  Meaning: putting back what you got does not change anything.

  PutPut, or ShoveShove:

        (= (shove data my-lens val-1)
           (shove (shove data my-lens val-2) my-lens val-1))

  Meaning: second shove wins, or shoving once is the same as shoving twice.

  A lens that satisfies these three laws is usually called \"very well-behaved\".
  See also `active.clojure.lens-test/lens-laws-hold`."
  (:require [active.clojure.functions :as f]
            [clojure.set :as set])
  (:refer-clojure :exclude [merge first second]))

(defn yank
  "Yank a value from the given data value, as defined by the given
   lens."
  [data lens]
  (lens data))

(defn shove
  "Shove a new value v into the given data value, as defined by the
   given lens, and return the updated data structure."
  [data lens v]
  (if (keyword? lens)
    (assoc data lens v)
    (lens data v)))

(defn- throw-invalid-number-of-arguments-error [n]
  (let [error-msg (str "invalid number of arguments (" n ") to lens")]
    (throw (java.lang.IllegalArgumentException. error-msg))))

(defrecord ExplicitLens
    ^{:private true}
  [yanker shover args]
  #?@(:clj [clojure.lang.IFn
            (invoke [this data] (apply yanker data args))
            (invoke [this data v] (apply shover data v args))
            (applyTo [this apply-args]
                     (let [apply-args (object-array apply-args)]
                       (case (count apply-args)
                         1 (apply yanker (aget apply-args 0) args)
                         2 (apply shover (aget apply-args 0) (aget apply-args 1) args)
                         (throw-invalid-number-of-arguments-error (count apply-args)))))]
      :cljs [IFn
             (-invoke [this data] (apply yanker data args))
             (-invoke [this data v] (apply shover data v args))]))

(defrecord ExplicitLensWithoutArgs<commit_msg>Remove defininition of a clj util from cljs.<commit_after>(ns active.clojure.lens
  "Lenses should obey the following laws:

  GetPut, or YankShove:

      (= (yank (shove data my-lens val)
               my-lens)
         val)

  Meaning: you get back what you put in.

  PutGet, or ShoveYank:

      (= (shove data
                my-lens
                (yank data my-lens))
         data)

  Meaning: putting back what you got does not change anything.

  PutPut, or ShoveShove:

        (= (shove data my-lens val-1)
           (shove (shove data my-lens val-2) my-lens val-1))

  Meaning: second shove wins, or shoving once is the same as shoving twice.

  A lens that satisfies these three laws is usually called \"very well-behaved\".
  See also `active.clojure.lens-test/lens-laws-hold`."
  (:require [active.clojure.functions :as f]
            [clojure.set :as set])
  (:refer-clojure :exclude [merge first second]))

(defn yank
  "Yank a value from the given data value, as defined by the given
   lens."
  [data lens]
  (lens data))

(defn shove
  "Shove a new value v into the given data value, as defined by the
   given lens, and return the updated data structure."
  [data lens v]
  (if (keyword? lens)
    (assoc data lens v)
    (lens data v)))

#?(:clj
   (defn- throw-invalid-number-of-arguments-error [n]
     (let [error-msg (str "invalid number of arguments (" n ") to lens")]
       (throw (java.lang.IllegalArgumentException. error-msg)))))

(defrecord ExplicitLens
    ^{:private true}
  [yanker shover args]
  #?@(:clj [clojure.lang.IFn
            (invoke [this data] (apply yanker data args))
            (invoke [this data v] (apply shover data v args))
            (applyTo [this apply-args]
                     (let [apply-args (object-array apply-args)]
                       (case (count apply-args)
                         1 (apply yanker (aget apply-args 0) args)
                         2 (apply shover (aget apply-args 0) (aget apply-args 1) args)
                         (throw-invalid-number-of-arguments-error (count apply-args)))))]
      :cljs [IFn
             (-invoke [this data] (apply yanker data args))
             (-invoke [this data v] (apply shover data v args))]))

(defrecord ExplicitLensWithoutArgs
{'fraction_non_alphanumeric': 0.10825318720644152, 'fraction_numerical': 0.0035786177588906284, 'mean_word_length': 2.2195824334053276, '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': '1181317', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1390, 'n_words': 503}