[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A not stupid question (no questions are stupid)
- From: RLake@...
- Date: Fri, 11 Jan 2002 12:38:11 -0500
>function change (src, find, rep)
> src = gsub (src, "(%w+)", function (word)
> if word == %find then
> return %rep
> else
> return word
> end
> end)
> return src
>end
>
Or:
function change(src, tab)
src = gsub(src, "(%w+)", function(word) return tab[word] or word end)
return src
end
src = change("this is the answer", {this = "these", is = "are", answer
= "answers"})
or even
function changer(tab)
return function(src)
src = gsub(src, "(%w+)", function(word) return %tab[word] or word
end)
end
end
pluralise = changer {this = "these", is = "are", answer = "answers"}
src = pluralise(src)