Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
random state and words generator
(ns honeycomb.core
(:gen-class)
(:require [clojure.string :as string]))
; Reads a file into an array (split by newline / \n)
(defn file->array
[filename]
(string/split-lines (slurp filename)))
; Some definitions of random arrays of STUFF
;States
(def states
(file->array "states.txt"))
; Words
(def words
(file->array "words.txt"))
; Grab a random element out of a PersistentVector
(defn grab
[v]
(nth v (rand-int (count v))))
; Generate n rows of data
; provide n (number of rows to generate)
; datesets (arbitrary amount of datsets to grab random elements from)
(defn seq-rows
[n & sets]
(map (fn [x]
(map grab sets)) (range n)))
(defn to->csv
[n]
(map (fn [x]
(reduce #(str %1 "," %2) x)) n))
(defn -main
"I don't do a whole lot."
[n & args]
(doseq
[x (seq-rows (Integer/parseInt n) states words words)] (println x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.