Udostępnij za pośrednictwem


Pig Latin

Pig Latin is a language game where you alter the English words. The goal is to conceal the meaning of the words from others not familiar with the rules (like you're talking in code or a secret language). The reference to Latin is a misnomer, because it has nothing to do with Latin. It'is simply a form of jargon, used only because it turns your English words into a strange and foreign-sounding language.

According to John R. Hailman's Thomas Jefferson on Wine, Thomas Jefferson used pig latin as a kid. This is one of the earliest known uses of pig latin.

 

For words that begin with consonant sounds, the initial consonant or consonant cluster is moved to the end of the word, and "ay" (some people just add "a") is added, as in the following examples:

  • "pig" → "igpay"
  • "banana" → "ananabay"
  • "trash" → "ashtray"
  • "happy" → "appyhay"
  • "duck" → "uckday"
  • "glove" → "oveglay"

For words which begin with vowel sounds or silent letter, one just adds "yay" to the end. Examples are:

  • "eat" → "eatyay"
  • "omelet" → "omeletyay"
  • "are" → "areyay"

  

Now that you know pig latin, let's program some in Small Basic!

 

While ("True")

   TextWindow.Write("Enter a word: ")

   word = TextWindow.Read()

   pigLatin = Text.GetSubTextToEnd(word, 2) 

   pigLatin = pigLatin + Text.GetSubText(word, 1, 1)

   pigLatin = pigLatin + "ay"                   

   TextWindow.WriteLine(pigLatin)                   

   TextWindow.WriteLine("") 

EndWhile

Do you have any questions? Ask us! We're full of answers and other fine things!

Head to the Small Basic forum to get the most answers to your questions: 

https://social.msdn.microsoft.com/Forums/en-US/smallbasic/threads/   

And go to https://blogs.msdn.com/SmallBasic to download Small Basic and learn all about it!

   

Small and Basically yours

- Ninja Ed

Comments

  • Anonymous
    August 19, 2015
    cute!

  • Anonymous
    August 22, 2015
    Ha! Thanks, Sean! This program just gets the basics of Pig Latin going. Folks can add more features to get all the nuances down!

  • Anonymous
    January 30, 2016
    Computers Today (part 1 of 6) blogs.msdn.com/.../computers-today.aspx .... CS SPOTLIGHT: Girls in computer programming... why it matters!!! blogs.msdn.com/.../cs-spotlight-girls-in-computer-programming-why-it-matters.aspx

  • Anonymous
    February 09, 2017
    how do i code for the vowels? How do i code it for a sentence?

    • Anonymous
      February 25, 2017
      That's the challenge. To add onto the code above and take it to the next level. Here's the logic:1. Take the code above.2. You check if each word begins with a vowel. If not, proceed as normal. If so, skip the text above, and instead just add "ay" or "yay" at the end of the word. So the code is actually simpler in comparison (you aren't removing the first letter and appending it at the end), but to check for the vowel condition and give both commands... that adds a bit to the code.