<commit_before>(ns aurora.language
  (:require [clojure.set :refer [union intersection difference subset?]])
  (:require-macros [aurora.macros :refer [console-time set!! conj!! disj!! assoc!! apush apush* avec]]
                   [aurora.language :refer [deffact]]))

(declare resolve)

(extend-protocol ISeqable
  TransientArrayMap
  (-seq [this]
        (if (.-editable? this)
          (persistent-array-map-seq (.-arr this) 0 nil)
          (throw (js/Error. "seq after persistent"))))
  TransientHashMap
  (-seq [this]
        (if (.-edit this)
          (when (pos? (.-count this))
            (let [s (if-not (nil? (.-root this)) (.inode-seq (.-root this)))]
              (if (.-has-nil? this)
                (cons [nil (.-nil-val this)] s)
                s)))
          (throw (js/Error. "seq after persistent"))))
  TransientHashSet
  (-seq [this]
        (keys (.-transient-map this))))

(defn arr= [arr-a arr-b]
  (and (== (alength arr-a) (alength arr-b))
       (loop [i 0]
         (if (>= i (alength arr-a))
           true
           (if (= (aget arr-a i) (aget arr-b i))
             (recur (+ i 1))
             false)))))

;; TODO facts and plans need to be serializable

;; FACTS

(deftype FactShape [id madlib keys]<commit_msg>Dont use clojure equality inside facts<commit_after>(ns aurora.language
  (:require [clojure.set :refer [union intersection difference subset?]])
  (:require-macros [aurora.macros :refer [console-time set!! conj!! disj!! assoc!! apush apush* avec]]
                   [aurora.language :refer [deffact]]))

(declare resolve)

(extend-protocol ISeqable
  TransientArrayMap
  (-seq [this]
        (if (.-editable? this)
          (persistent-array-map-seq (.-arr this) 0 nil)
          (throw (js/Error. "seq after persistent"))))
  TransientHashMap
  (-seq [this]
        (if (.-edit this)
          (when (pos? (.-count this))
            (let [s (if-not (nil? (.-root this)) (.inode-seq (.-root this)))]
              (if (.-has-nil? this)
                (cons [nil (.-nil-val this)] s)
                s)))
          (throw (js/Error. "seq after persistent"))))
  TransientHashSet
  (-seq [this]
        (keys (.-transient-map this))))

(defn arr= [arr-a arr-b]
  (and (== (alength arr-a) (alength arr-b))
       (loop [i 0]
         (if (>= i (alength arr-a))
           true
           (if (== (aget arr-a i) (aget arr-b i))
             (recur (+ i 1))
             false)))))

;; TODO facts and plans need to be serializable

;; FACTS

(deftype FactShape [id madlib keys]
{'fraction_non_alphanumeric': 0.16653481012658228, 'fraction_numerical': 0.0023734177215189874, 'mean_word_length': 2.0916870415647923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '629190', 'n_tokens_mistral': 862, 'n_tokens_neox': 844, 'n_words': 252}