• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Nice Automator article on O'Reilly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nice Automator article on O'Reilly


  • Subject: Re: Nice Automator article on O'Reilly
  • From: kai <email@hidden>
  • Date: Sat, 7 May 2005 02:56:56 +0100


On Friday, May 6, 2005, at 11:49 pm, Gary (Lists) wrote:

"David Marshall" wrote:

Years ago I was able to write an absurd little command-line program that
took as input an English word and returned its Pig Latin equivalent. (Try
THAT in AppleScript!)

Sloppy, poor Pig Grammar and no punctuation but funny, nonetheless.

--
property vowels : {"a", "e", "i", "o", "u"}
property noPig : {"the"}
set mySentence to "Gary thinks the Xcode list reads like Martians at a
party"
set myWords to words of mySentence
set pigWords to {}
repeat with aWord in myWords
    if (aWord is not in noPig) and [NOBREAK]
       (text item 1 of aWord is not in vowels) and [NOBREAK]
       (length of aWord > 3) then
        set wti to text items of aWord
        set moveChar to item 1 of wti
        set aWord to (the rest of wti as text) & "-" & moveChar & "ay"
    end if
    copy aWord & " " to end of pigWords
end repeat
set pigSentence to (pigWords as text)

--> "ary-Gay hinks-tay the code-Xay ist-lay eads-ray ike-lay artians-May at
a arty-pay "

I really shouldn't encourage you in this, Gary - but, retaining the charm of the sloppy grammar, here's the punctuation:


on pigText(t)
	set r to ""
	repeat with w in t's words
		set text item delimiters to w
		if (count w) > 3 then tell w's item 1 ¬
			to if it is not in "aeiou" then set w ¬
			to w's text 2 thru -1 & "-" & it & "ay"
		set r to r & t's text item 1 & w
		set t to t's text from text item 2 to -1
	end repeat
	r & t
end pigText

pigText("Gary thinks the Xcode list reads like: 'Martians at a party'!")

--> "ary-Gay hinks-tay the code-Xay ist-lay eads-ray ike-lay: 'artians-May at a arty-pay'!"

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Nice Automator article on O'Reilly (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Re: new todo in iCal
  • Next by Date: Re: new todo in iCal
  • Previous by thread: Re: Nice Automator article on O'Reilly
  • Next by thread: Re: Nice Automator article on O'Reilly
  • Index(es):
    • Date
    • Thread