Created
March 23, 2015 18:58
-
-
Save CliffordAnderson/e75fd3e4e3e569a661cf to your computer and use it in GitHub Desktop.
Pig Latin Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
(: Takes a sentence in English and converts it to its equivalent in Pig Latin :) | |
(: Note that this expression does not handle punction :) | |
fn:string-join( | |
let $sentence := "I speak Pig Latin" | |
let $words := fn:tokenize($sentence, " ") | |
for $word in $words | |
let $vowels := ("a","e","i","o","u","y") | |
let $first-letter := fn:lower-case(fn:substring($word,1,1)) | |
return | |
if ($first-letter = $vowels) then $word || "ay" | |
else fn:substring($word,2) || $first-letter || "ay" | |
, " ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment