<commit_before>; An attempt to use in-place array mutation in Clojure
; Highly non-idiomatic. Should not be used. EXPERIMENTAL.
; Also it is ridiculously slow. Does anyone know why?

(defn generatePermutations [a n]
  (if (zero? n)
    (println (apply str a))
    (doseq [i (range 0 (inc n))]
      (generatePermutations a (dec n))
      (let [j (if (even? n) i 0) oldn (aget a n) oldj (aget a j)]
        (aset a n oldj) (aset a j oldn)))))

(if (not= (count *command-line-args*) 1)
  (do
    (println "Exactly one argument is required")
    (System/exit 1))
  (let [word (-> *command-line-args* first vec to-array)]
    (time (generatePermutations word (dec (count word))))))<commit_msg>Use char arrays and type hints<commit_after>; An attempt to use in-place array mutation in Clojure
; Highly non-idiomatic. Should not be used. EXPERIMENTAL.
; Also it is ridiculously slow. Does anyone know why?

(defn generatePermutations [^chars a n]
  (if (zero? n)
    ();(println (apply str a))
    (doseq [i (range 0 (inc n))]
      (generatePermutations a (dec n))
      (let [j (if (even? n) i 0) oldn (aget a n) oldj (aget a j)]
        (aset-char a n oldj) (aset-char a j oldn)))))

(if (not= (count *command-line-args*) 1)
  (do
    (println "Exactly one argument is required")
    (System/exit 1))
  (let [word (-> *command-line-args* first vec char-array)]
    (time (generatePermutations word (dec (count word))))))
{'fraction_non_alphanumeric': 0.1397318278052223, 'fraction_numerical': 0.0056457304163726185, 'mean_word_length': 3.3363914373088686, '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': '6859484', 'n_tokens_mistral': 514, 'n_tokens_neox': 487, 'n_words': 197}