diff options
author | Ben Sima <ben@bsima.me> | 2018-06-13 21:36:56 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2018-06-13 21:36:56 -0700 |
commit | 77c9a177b2b595d4ce25095b58e2388fe33cc97a (patch) | |
tree | 0853d5c92d67538760005b9c4635a90115bd7ba4 /roun |
init
Diffstat (limited to 'roun')
-rwxr-xr-x | roun | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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*)))) |