Skip to content

Instantly share code, notes, and snippets.

@marklap
Last active August 29, 2015 14:01
Show Gist options
  • Save marklap/979f7ab4901638f5eb97 to your computer and use it in GitHub Desktop.
Save marklap/979f7ab4901638f5eb97 to your computer and use it in GitHub Desktop.
pig latin
package main
import "fmt"
import "strings"
import "unicode"
var msg_orig = "Hello World! This is the best ever"
var vowels = "aeiou"
func main() {
split := func (r rune) bool {
return !unicode.IsLetter(r)
}
words := strings.FieldsFunc(msg_orig, split)
for _, word := range words {
if strings.ContainsAny(string(word[0]), vowels) {
word = strings.ToLower(word + "ay")
} else {
word = strings.ToLower(word[1:] + string(word[0]) + "ay")
}
fmt.Println(word)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment