Qbasicnews.com
December 09, 2019, 06:38:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Piglatin  (Read 8739 times)
Neo
Na_th_an
*****
Posts: 2150



« Reply #15 on: May 23, 2003, 10:37:45 AM »

wtf is piglatin?
Logged
Dav
Administrator
Ancient Guru
*****
Posts: 709



WWW
« Reply #16 on: May 23, 2003, 11:01:12 AM »

It's a silly but popular english language game.  Words beginning with vowels have "WAY" attached to it ('igloo' becomes 'igloo-way').  If a word has constants at the beginning, they're move to the end with "AY" at the end. ('string' becomes ing-stray).  Words beginning with QU are done like this. ('quest' becomes 'est-quay')

It's worthless talk, but became very popular in the US among both kids and adults.

Here's my last try.  This one parses, but periods, question marks, etc,  are not handled.  

Code:

DECLARE FUNCTION Piggy$ (In$)

PRINT Piggy$("what is pig latin that is the question")
PRINT Piggy$("hello my name is dave and i'm a pig")
PRINT
INPUT "What do you say, pig"; A$
PRINT Piggy$(A$)

FUNCTION Piggy$ (In$)

Out$ = ""

DO UNTIL w >= LEN(In$)
    '=== Parse a word...
    temp$ = ""
    WHILE MID$(In$, w + 1, 1) <> " " AND MID$(In$, w + 1, 1) <> ""
        temp$ = temp$ + MID$(In$, w + 1, 1)
        w = w + 1
    WEND
    '====== piggy it ====
    FOR x% = 1 TO LEN(temp$)
      SELECT CASE UCASE$(MID$(temp$, x%, 1))
        CASE IS = "A", "E", "I", "O", "U", "Y": EXIT FOR
      END SELECT
    NEXT
    '=== If vowel first...
    IF x% = 1 THEN
       Out$ = Out$ + temp$ + "-way "
    '=== If starts with "qu"...
    ELSEIF UCASE$(LEFT$(temp$, 2)) = "QU" THEN
       Out$ = Out$ + RIGHT$(temp$, LEN(temp$) - 2)
       Out$ = Out$ + "-" + LEFT$(temp$, 2) + "ay "
    '=== else...
    ELSE
       L$ = LEFT$(temp$, x% - 1)
       R$ = MID$(temp$, x%, LEN(temp$))
       Out$ = Out$ + R$ + "-" + L$ + "ay "
    END IF
    '====================
    w = w + 1
LOOP

Piggy$ = Out$

END FUNCTION



- Dav
Logged

Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!