Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
random state and words generator
(ns honeycomb.core
(:require [clojure.string :as string]))
; Reads a file into an array (split by newline / \n)
(defn file->array
(string/split-lines (slurp filename)))
; Some definitions of random arrays of STUFF
(def states
(file->array "states.txt"))
; Words
(def words
(file->array "words.txt"))
; Grab a random element out of a PersistentVector
(defn grab
(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
(map (fn [x]
(reduce #(str %1 "," %2) x)) n))
(defn -main
"I don't do a whole lot."
[n & args]
[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.