First commit
This commit is contained in:
13
exercises/ch04/ex4_4.lua
Normal file
13
exercises/ch04/ex4_4.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
local function insert(str, i, o)
|
||||
i = utf8.offset(str, i)
|
||||
local first_half = str:sub(1, i - 1)
|
||||
local latter_half = str:sub(i, -1)
|
||||
return first_half .. o .. latter_half
|
||||
end
|
||||
|
||||
local function tests()
|
||||
local res = insert("ação", 5, "!")
|
||||
print(('insert("ação", 5, "!") --> %s'):format(res))
|
||||
end
|
||||
|
||||
tests()
|
||||
Reference in New Issue
Block a user