Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Phrase-reversals/MiniScript/phrase-reversals.mini
Normal file
24
Task/Phrase-reversals/MiniScript/phrase-reversals.mini
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
phrase = "rosetta code phrase reversal"
|
||||
|
||||
// general sequence reversal function
|
||||
reverse = function(seq)
|
||||
out = []
|
||||
for i in range(seq.len-1, 0)
|
||||
out.push seq[i]
|
||||
end for
|
||||
if seq isa string then return out.join("")
|
||||
return out
|
||||
end function
|
||||
|
||||
// 1. Reverse the characters of the string.
|
||||
print reverse(phrase)
|
||||
|
||||
// 2. Reverse the characters of each individual word in the string, maintaining original word order within the string.
|
||||
words = phrase.split
|
||||
for i in words.indexes
|
||||
words[i] = reverse(words[i])
|
||||
end for
|
||||
print words.join
|
||||
|
||||
// 3. Reverse the order of each word of the string, maintaining the order of characters in each word.
|
||||
print reverse(phrase.split).join
|
||||
Loading…
Add table
Add a link
Reference in a new issue