Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
14
Task/Phrase-reversals/EchoLisp/phrase-reversals.echolisp
Normal file
14
Task/Phrase-reversals/EchoLisp/phrase-reversals.echolisp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(define (string-reverse string)
|
||||
(list->string (reverse (string->list string))))
|
||||
|
||||
(define (task str)
|
||||
(for-each writeln (list
|
||||
(string-reverse str)
|
||||
(string-join (map string-reverse (string-split str )))
|
||||
(string-join (reverse (string-split str ))))))
|
||||
|
||||
|
||||
(task "rosetta code phrase reversal")
|
||||
"lasrever esarhp edoc attesor"
|
||||
"attesor edoc esarhp lasrever"
|
||||
"reversal phrase code rosetta"
|
||||
64
Task/Phrase-reversals/FreeBASIC/phrase-reversals.freebasic
Normal file
64
Task/Phrase-reversals/FreeBASIC/phrase-reversals.freebasic
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Sub split (s As Const String, sepList As Const String, result() As String)
|
||||
If s = "" OrElse sepList = "" Then
|
||||
Redim result(0)
|
||||
result(0) = s
|
||||
Return
|
||||
End If
|
||||
Dim As Integer i, j, count = 0, empty = 0, length
|
||||
Dim As Integer position(Len(s) + 1)
|
||||
position(0) = 0
|
||||
|
||||
For i = 0 To len(s) - 1
|
||||
For j = 0 to Len(sepList) - 1
|
||||
If s[i] = sepList[j] Then
|
||||
count += 1
|
||||
position(count) = i + 1
|
||||
End If
|
||||
Next j
|
||||
Next i
|
||||
|
||||
Redim result(count)
|
||||
If count = 0 Then
|
||||
result(0) = s
|
||||
Return
|
||||
End If
|
||||
|
||||
position(count + 1) = len(s) + 1
|
||||
|
||||
For i = 1 To count + 1
|
||||
length = position(i) - position(i - 1) - 1
|
||||
result(i - 1) = Mid(s, position(i - 1) + 1, length)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Function reverse(s As Const String) As String
|
||||
If s = "" Then Return ""
|
||||
Dim t As String = s
|
||||
Dim length As Integer = Len(t)
|
||||
For i As Integer = 0 to length\2 - 1
|
||||
Swap t[i], t[length - 1 - i]
|
||||
Next
|
||||
Return t
|
||||
End Function
|
||||
|
||||
Dim s As String = "rosetta code phrase reversal"
|
||||
Dim a() As String
|
||||
Dim sepList As String = " "
|
||||
|
||||
Print "Original string => "; s
|
||||
Print "Reversed string => "; reverse(s)
|
||||
Print "Reversed words => ";
|
||||
split s, sepList, a()
|
||||
For i As Integer = LBound(a) To UBound(a)
|
||||
Print reverse(a(i)); " ";
|
||||
Next
|
||||
Print
|
||||
Print "Reversed order => ";
|
||||
For i As Integer = UBound(a) To LBound(a) Step -1
|
||||
Print a(i); " ";
|
||||
Next
|
||||
Print : Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
3
Task/Phrase-reversals/Oforth/phrase-reversals.oforth
Normal file
3
Task/Phrase-reversals/Oforth/phrase-reversals.oforth
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
"rosetta code phrase reversal" reverse println
|
||||
"rosetta code phrase reversal" words map(#reverse) unwords println
|
||||
"rosetta code phrase reversal" words reverse unwords println
|
||||
8
Task/Phrase-reversals/Phix/phrase-reversals.phix
Normal file
8
Task/Phrase-reversals/Phix/phrase-reversals.phix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
constant test="rosetta code phrase reversal"
|
||||
?reverse(test)
|
||||
sequence words = split(reverse(test))
|
||||
for i=1 to length(words) do
|
||||
words[i] = reverse(words[i])
|
||||
end for
|
||||
?join(words)
|
||||
?join(reverse(words))
|
||||
9
Task/Phrase-reversals/Ring/phrase-reversals.ring
Normal file
9
Task/Phrase-reversals/Ring/phrase-reversals.ring
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
aString = "Welcome to the Ring Language"
|
||||
bString = ""
|
||||
see reverseString(aString)
|
||||
|
||||
func reverseString cString
|
||||
for i= len(cString) to 1 step -1
|
||||
bString = bString + cString[i]
|
||||
next
|
||||
return bString
|
||||
5
Task/Phrase-reversals/Sidef/phrase-reversals.sidef
Normal file
5
Task/Phrase-reversals/Sidef/phrase-reversals.sidef
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var str = "rosetta code phrase reversal";
|
||||
|
||||
say str.reverse; # reversed string
|
||||
say str.words.map{.reverse}.join(' '); # words reversed
|
||||
say str.words.reverse.join(' '); # word order reversed
|
||||
8
Task/Phrase-reversals/jq/phrase-reversals.jq
Normal file
8
Task/Phrase-reversals/jq/phrase-reversals.jq
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def reverse_string: explode | reverse | implode;
|
||||
|
||||
"rosetta code phrase reversal"
|
||||
| split(" ") as $words
|
||||
| "0. input: \(.)",
|
||||
"1. string reversed: \(reverse_string)",
|
||||
"2. each word reversed: \($words | map(reverse_string) | join(" "))",
|
||||
"3. word-order reversed: \($words | reverse | join(" "))"
|
||||
Loading…
Add table
Add a link
Reference in a new issue