summaryrefslogtreecommitdiff
path: root/roun
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
committerBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
commit77c9a177b2b595d4ce25095b58e2388fe33cc97a (patch)
tree0853d5c92d67538760005b9c4635a90115bd7ba4 /roun
init
Diffstat (limited to 'roun')
-rwxr-xr-xroun27
1 files changed, 27 insertions, 0 deletions
diff --git a/roun b/roun
new file mode 100755
index 0000000..54447dd
--- /dev/null
+++ b/roun
@@ -0,0 +1,27 @@
+#!/usr/bin/env racket
+#lang racket/base
+
+;; http://www.flipcode.com/archives/Generating_Names_Phonetically.shtml
+
+(define consonants '(#\b #\c #\d #\f #\g #\h #\j #\k #\l #\m #\n #\p #\q #\r #\s #\t #\v #\w #\x #\y #\z))
+(define c-len (length consonants))
+(define (rand-consonant) (list-ref consonants (random c-len)))
+
+(define vowels '(#\a #\e #\i #\o #\u))
+(define v-len (length vowels))
+(define (rand-vowel) (list-ref vowels (random v-len)))
+
+(define generate-roun
+ (lambda ()
+ (string
+ (rand-consonant) (rand-vowel) (rand-consonant))))
+
+(define *help*
+ "roun :: generates random consonant-vowel-consonant words")
+
+(let ((args (current-command-line-arguments)))
+ (cond
+ ((= 0 (vector-length args))
+ (printf "~a\n" (generate-roun)))
+
+ (else (printf "~a\n" *help*))))