giblang

This is a (slightly) modified version of a Janet script originally made by Paul Batchelor. It generates strings of gibberish that are more or less pronounceable.

# Modified from the original, https://pbat.ch/wiki/giblang/

(def cons (array
           "b" "c" "d" "f"
           "g" "h" "j" "k"
           "l" "m" "n" "p"
           "r" "s" "t" "v"
           "w" "z" "ch" "sh"
           "zh" "th"))

(def vow (array "a" "e" "i" "o" "u" "y" "ee" "ai" "ae"))

(defn rpick (t)
  (t (math/floor (* (math/random) (length t)))))

(defn seed () (math/seedrandom (os/time)))

(defn syl () (string (rpick cons) (rpick vow)))

(defn word ()
  (do
    (var str "")
    (for i 0 (+ (math/floor (* (math/random) 3)) 1)
      (set str (string str (syl))))
    (cond (> (math/random) 0.2)
          (set str (string str (rpick cons))))
    (string str)))

(defn speak [number-of-words]
  (seed)
  (var words "")
  (var i 0)
  (while (< i number-of-words)
      (set words (string words (word) " "))
      (++ i))
  (print words))

(speak 7)