aark@ihuxe.UUCP (09/03/83)
First, Mr. Art Zemon's English-to-Pig-Latin translator, written using Lex, does not translate correctly, at least according to the Pig Latin I learned: - Words beginning with a vowel are translated by appending "way", not "yay". - Sometimes an initial "y" is a vowel, as in "yttrium," and must be treated as such. Zemon's translator does not. - For words that begin with more than one consonant, ALL these consonants, not just the first, are put at the end, then "ay" is appended. (An initial "qu" is a special case that Zemon's translator does not handle either.) Second, this problem can be solved with an even shorter and easier program if you use a language suited to the problem, namely Lisp. (defun englishtopig (sentence) (mapcar 'etop1 sentence) ) (defun etop1 (word) (implode (etop2 (explode word))) ) (defun etop2 (letterlist) (cond ((and (equal (car letterlist) '@) (vowel (cadr letterlist))) (append (cdr letterlist) '(ay))) ((equal (car letterlist) '@) (etop2 (append '(@) (cddr letterlist) (list (cadr letterlist))))) ((and (equal (car letterlist) 'q) (equal (cadr letterlist) 'u)) (append (cddr letterlist) '(quay))) ((and (equal (car letterlist) 'y) (not (vowel (cadr letterlist)))) (append letterlist '(way))) ((vowel (car letterlist)) (append letterlist '(way))) (t (etop2 (cons '@ letterlist))) ) ) (defun vowel (letter) (or (equal letter 'a) (equal letter 'e) (equal letter 'i) (equal letter 'o) (equal letter 'u) ) ) You can't read this program, you say? Maybe you should learn Lisp. You can write many (not all) programs a lot more easily in Lisp than in C, even C augmented with code generators like Lex, and this is one of them. -- Alan R. Kaminsky Bell Laboratories, Naperville, IL ...ihnp4!ihuxe!aark
dave@utcsrgv.UUCP (Dave Sherman) (09/04/83)
OK guys, who's coming up with an awk script to do Pig Latin? Or maybe sed? -- {allegra,cornell,floyd,ihnp4,linus,utzoo,uw-beaver,watmath}!utcsrgv!lsuc!dave
presley@mhuxj.UUCP (09/05/83)
I'm not going to be satisfied until someone comes up with a description of a Turing machine that does it -:). -- Joe Presley (...!mhuxj!presley, harpo!presley)