<commit_before>;; Copyright (c) <NAME>. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file LICENSE at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.

(ns conexp.base)

(load "util")

(ns-doc "Basic definitions for conexp-clj.")

;;; Very Basic Set Theory

(defn cross-product
  "Returns cross product of set-1 and set-2."
  [& sets]
  (if (empty? sets)
    #{[]}
    (set-of (conj t x) [t (apply cross-product (butlast sets))
                        x (last sets)])))

(defn disjoint-union
  "Computes the disjoint union of sets by joining the cross-products of the
  sets with natural numbers."
  [& sets]
  (apply union (map #(cross-product %1 #{%2}) sets (iterate inc 0))))

(defn set-of-range
  "Returns a set of all numbers from start upto (but not including) end,
  by step if provided."
  ([end]
     (set-of-range 0 end 1))
  ([start end]
     (set-of-range start end 1))
  ([start end step]
     (set (range start end step))))

(defn to-set
  "Converts given argument «thing» to a set. If it is a number,
  returns the set {0, ..., thing-1}. If it is a collection,
  returns (set thing). Otherwise raises an error."
  [thing]
  (cond
   (integer? thing) (set-of-range thing),
   (coll? thing)    (set thing),
   :else            (illegal-argument "Cannot create set from " thing)))


;;; Next Closure

(defn lectic-<_i
  "Implements lectic < at position i. The basic order is given by the ordering
  of base which is interpreted as increasing order.

  A and B have to be sets."<commit_msg>Allow seqable things to be come sets<commit_after>;; Copyright (c) <NAME>. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file LICENSE at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.

(ns conexp.base)

(load "util")

(ns-doc "Basic definitions for conexp-clj.")

;;; Very Basic Set Theory

(defn cross-product
  "Returns cross product of set-1 and set-2."
  [& sets]
  (if (empty? sets)
    #{[]}
    (set-of (conj t x) [t (apply cross-product (butlast sets))
                        x (last sets)])))

(defn disjoint-union
  "Computes the disjoint union of sets by joining the cross-products of the
  sets with natural numbers."
  [& sets]
  (apply union (map #(cross-product %1 #{%2}) sets (iterate inc 0))))

(defn set-of-range
  "Returns a set of all numbers from start upto (but not including) end,
  by step if provided."
  ([end]
     (set-of-range 0 end 1))
  ([start end]
     (set-of-range start end 1))
  ([start end step]
     (set (range start end step))))

(defn to-set
  "Converts given argument «thing» to a set. If it is a number,
  returns the set {0, ..., thing-1}. If it is a collection,
  returns (set thing). Otherwise raises an error."
  [thing]
  (cond
   (integer? thing) (set-of-range thing),
   (seqable? thing) (set thing),
   :else            (illegal-argument "Cannot create set from " thing)))


;;; Next Closure

(defn lectic-<_i
  "Implements lectic < at position i. The basic order is given by the ordering
  of base which is interpreted as increasing order.

  A and B have to be sets."
{'fraction_non_alphanumeric': 0.1157750342935528, 'fraction_numerical': 0.007681755829903978, 'mean_word_length': 3.1244343891402715, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2599215', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1123, 'n_words': 519}