Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. local dict = {
  2. a = "あ",
  3. i = "い",
  4. u = "う",
  5. e = "え",
  6. o = "お"
  7. }
  8.  
  9. local function roman_to_japanese(text)
  10. local converted = ""
  11. while text ~= "" do
  12. local ok = false
  13. for i = 1, 3 do
  14. local subbed = text:sub(1, i)
  15. if dict[subbed] then
  16. converted = converted..dict[subbed]
  17. text = text:sub(i + 1, -1)
  18. ok = true
  19. break
  20. end
  21. end
  22. if not ok then
  23. error("no!")
  24. end
  25. end
  26. return converted
  27. end
  28.  
  29. print(roman_to_japanese("aiueoaieueo"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement