I'm sorry for the bad subject, but I could not find anything better.
Some times ago I was talking with a friend of mine, and we compared newLisp vs other imperative languages (object pascal, generic basic, and java).
We tried to make small programs to get an input and produce same output, but using the best of each sector ("imperative" concepts and "functional" ones).
Well, I'm working in newLisp but I come from many years programming with imperative languages. So sometimes is difficult for me using advance functional algorithms since I tend to use "imperative" concepts to solve problems in newLisp.
(sorry for this long introduction!)
This is the "trivial" problem:
I have a list of strings, and I want to convert only some strings to upper-case. The strings are: first string, third string, 5th string, etc...
So... I have:
("string 1" "string 2" "string 3" "string 4" "string 5" "string 6")
I want to obtain:
("STRING 1" "string 2" "STRING 3" "string 4" "STRING 5" "string 6")
In an "imperative algorithm" I could use a loop and a "step". For example:
Code: Select all
dim myList$(6)
myList$(1) = "string 1"
myList$(2) = "string 2"
myList$(3) = "string 3"
myList$(4) = "string 4"
myList$(5) = "string 5"
myList$(6) = "string 6"
for i=1 to 6 step 2
myList$(i) = uppercase(myList$(i))
next
How many possibilities/alternatives do I have to accomplish it?
(I wish to insert the results of this topic even in my blog, since I think this discussion could be interesting even for many other guys).
Thank you!