Paste number 17856: Cleaned up JackaLX' code

Paste number 17856: Cleaned up JackaLX' code
Pasted by: PeanutHorst
When:5 years, 10 months ago
Share:Tweet this! | http://paste.lisp.org/+DS0
Channel:#xemacs
Paste contents:
Raw Source | XML | Display As
(defvar phonetics-hash
  #s(hash-table test equal
		data ("a" "alpha"
		      "b" "bravo"
		      "c" "charlie"
		      "d" "delta"
		      "e" "echo"
		      "f" "foxtrot"
		      "g" "golf"
		      "h" "hotel"
		      "i" "india"
		      "j" "juliet"
		      "k" "kilo"
		      "l" "lima"
		      "m" "mike"
		      "n" "november"
		      "o" "oscar"
		      "p" "papa"
		      "q" "quebec"
		      "r" "romeo"
		      "s" "sierra"
		      "t" "tango"
		      "u" "uniform"
		      "v" "victor"
		      "w" "whiskey"
		      "x" "x-ray"
		      "y" "yankee"
		      "z" "zulu"
		      "." "stop"
		      "," "comma"
		      ":" "colon"
		      ";" "semicolon"
		      "!" "exclamation"
		      "?" "question"
		      " " "SPC"
		      "0" "zero"
		      "1" "one"
		      "2" "two"
		      "3" "three"
		      "4" "fower"
		      "5" "fife"
		      "6" "six"
		      "7" "seven"
		      "8" "eight"
		      "9" "niner"))
  "Hash table of phonetic alphabet.")

(defun phoneticize (string)
  "Return STRING rewritten using the phonetic alphabet.

For example: \"cat\" => \"charlie alpha tango\".
It ignores punctuation."
  (interactive "sString to phoneticize: ")
  (let ((str (string-to-list (downcase string)))
	phonetics)
    (with-temp-buffer
      (while str
	(insert (or (gethash (char-to-string (car str)) phonetics-hash)
		    (char-to-string (car str))) " ")
	(setq str (cdr str)))
      (setq phonetics (buffer-string)))
    (if current-prefix-arg
	(insert phonetics)
      (if (interactive-p)
	  (message "%s" phonetics)
	phonetics))))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.