Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1 @@
"abc" s:rev

View file

@ -0,0 +1,3 @@
String str = 'Hello World!';
str = str.reverse();
system.debug(str);

View file

@ -0,0 +1,2 @@
⌽'asdf'
fdsa

View file

@ -0,0 +1,15 @@
PROGRAM REVERSE_STRING
PROCEDURE REVERSE(A$->R$)
LOCAL I%
R$=""
FOR I=1 TO LEN(A$) DO
R$=MID$(A$,I,1)+R$
END FOR
END PROCEDURE
BEGIN
A$="THE FIVE BOXING WIZARDS JUMP QUICKLY"
REVERSE(A$->R$)
PRINT(R$)
END PROGRAM

View file

@ -0,0 +1,7 @@
(define (string-reverse string)
(list->string (reverse (string->list string))))
(string-reverse "ghij")
→ jihg
(string-reverse "un roc lamina l animal cornu")
→ unroc lamina l animal cor nu

View file

@ -0,0 +1,39 @@
-- The import on the next line provides the reverse string
-- functionality satisfying the rosettacode.org task description.
import String exposing (reverse)
-- The rest is fairly boilerplate code demonstrating
-- interactively that the reverse function works.
import Html exposing (Html, Attribute, text, div, input)
import Html.Attributes exposing (placeholder, value, style)
import Html.Events exposing (on, targetValue)
import Html.App exposing (beginnerProgram)
main = beginnerProgram { model = "", view = view, update = update }
update newStr oldStr = newStr
view : String -> Html String
view forward =
div []
([ input
[ placeholder "Enter a string to be reversed."
, value forward
, on "input" targetValue
, myStyle
]
[]
] ++
[ let backward = reverse forward
in div [ myStyle] [text backward]
])
myStyle : Attribute msg
myStyle =
style
[ ("width", "100%")
, ("height", "20px")
, ("padding", "5px 0 0 5px")
, ("font-size", "1em")
, ("text-align", "left")
]

View file

@ -0,0 +1,44 @@
## இந்த நிரல் தரப்படும் சரம் ஒன்றைத் தலைகீழாகத் திருப்பி அச்சிடும்
## உதாரணமாக "abc" என்ற சரம் தரப்பட்டால் அதனைத் திருப்பி "cba" என அச்சிடும்
## "எழில்" மொழியின்மூலம் இரண்டு வகைகளில் இதனைச் செய்யலாம். இரண்டு உதாரணங்களும் இங்கே தரப்பட்டுள்ளன
நிரல்பாகம் திருப்புக (சரம்1)
## முதல் வகை
சரம்2 = ""
@( சரம்1 இல் இ) ஒவ்வொன்றாக
சரம்2 = இ + சரம்2
முடி
பின்கொடு சரம்2
முடி
நிரல்பாகம் மீண்டும்திருப்புக (சரம்1)
## இரண்டாம் வகை
சரநீளம் = len(சரம்1)
சரம்2 = ""
@(எண் = 0, எண் < சரநீளம், எண் = எண் + 1) ஆக
சரம்2 = எடு(சரம்1, எண்) + சரம்2
முடி
பின்கொடு சரம்2
முடி
அ = உள்ளீடு("ஓர் எழுத்துச் சரத்தைத் தாருங்கள் ")
பதிப்பி "நீங்கள் தந்த எழுத்துச் சரம்" அ
பதிப்பி "அதனை முதல் வகையில் திருப்பியுள்ளோம்: " திருப்புக(அ)
பதிப்பி "வேறொரு வகையில் திருப்பியுள்ளோம்: " மீண்டும்திருப்புக(அ)

View file

@ -0,0 +1,14 @@
' FB 1.05.0 Win64
Function ReverseString(s As Const String) As String
If s = "" Then Return s
Dim length As Integer = Len(s)
Dim r As String = Space(length)
For i As Integer = 0 To length - 1
r[i] = s[length - 1 - i]
Next
Return r
End Function
Dim s As String = "asdf"
Print "'"; s; "' reversed is '"; ReverseString(s); "'"

View file

@ -0,0 +1,13 @@
include "ConsoleWindow"
dim as Str31 str
dim as long i
str = "123456789abcdefghijk"
print str
print
for i = str[0] to 1 step -1
print mid$( str, i, 1 );
next i

View file

@ -0,0 +1,10 @@
PRINT @reverse$("asdf")
'
FUNCTION reverse$(string$)
LOCAL result$,i%
result$=""
FOR i%=1 TO LEN(string$)
result$=MID$(string$,i%,1)+result$
NEXT i%
RETURN result$
ENDFUNC

View file

@ -0,0 +1,9 @@
FUNCTION Reverse( sIn )
LOCAL cOut := "", i
FOR i := Len( sIn ) TO 1 STEP -1
cOut += Substr( sIn, i, 1 )
NEXT
RETURN cOut

View file

@ -0,0 +1,6 @@
(include "string" "algorithm")
(main
(decl std::string s)
(std::getline std::cin s)
(std::reverse (s.begin) (s.end))
(prn s))

View file

@ -0,0 +1,35 @@
.ORIG 0x3000
LEA R1,STRING
LEA R2,GNIRTS
LD R3,MINUS1
NOT R5,R1
ADD R5,R5,1
SCAN LDR R4,R1,0
BRZ COPY
ADD R1,R1,1
BRNZP SCAN
COPY ADD R1,R1,R3
ADD R4,R1,R5
BRN COPIED
LDR R4,R1,0
STR R4,R2,0
ADD R2,R2,1
BRNZP COPY
COPIED AND R4,R4,0
STR R4,R2,0
LEA R0,GNIRTS
PUTS
HALT
MINUS1 .FILL 0xFFFF
STRING .STRINGZ "If thou beest he -- but O how fall'n! how chang'd"
GNIRTS .BLKW 128
.END

View file

@ -0,0 +1,2 @@
> (lists:reverse "asdf")
"fdsa"

View file

@ -0,0 +1,2 @@
> (set encoded (binary ("åäö ð" utf8)))
#B(195 165 195 164 195 182 32 195 176)

View file

@ -0,0 +1,2 @@
> (io:format "~tp~n" (list encoded))
<<"åäö ð"/utf8>>

View file

@ -0,0 +1,2 @@
> (lists:reverse (unicode:characters_to_list encoded))
"ð öäå"

View file

@ -0,0 +1,2 @@
local(input) = 'asdf'
#input->reverse

View file

@ -0,0 +1,4 @@
local(input = 'asdf', output = array)
with i in #input->values
do #output->insertFirst(#i)
#output->join

View file

@ -0,0 +1,7 @@
on reverse (str)
res = ""
repeat with i = str.length down to 1
put str.char[i] after res
end repeat
return res
end

View file

@ -0,0 +1,8 @@
on reverseBytes (str)
ba = byteArray(str)
res = byteArray()
repeat with i = ba.length down to 1
res[res.length+1] = ba[i]
end repeat
return res
end

View file

@ -0,0 +1,6 @@
function reverseString S
repeat with i = length(S) down to 1
put char i of S after R
end repeat
return R
end reverseString

View file

@ -0,0 +1,39 @@
import unicode
proc reverse(s: var string) =
for i in 0 .. s.high div 2:
swap(s[i], s[s.high - i])
proc reversed(s: string): string =
result = newString(s.len)
for i,c in s:
result[s.high - i] = c
proc uniReversed(s: string): string =
result = newStringOfCap(s.len)
var tmp: seq[Rune] = @[]
for r in runes(s):
tmp.add(r)
for i in countdown(tmp.high, 0):
result.add(toUtf8(tmp[i]))
proc isComb(r: Rune): bool =
(r >=% Rune(0x300) and r <=% Rune(0x36f)) or
(r >=% Rune(0x1dc0) and r <=% Rune(0x1dff)) or
(r >=% Rune(0x20d0) and r <=% Rune(0x20ff)) or
(r >=% Rune(0xfe20) and r <=% Rune(0xfe2f))
proc uniReversedPreserving(s: string): string =
result = newStringOfCap(s.len)
var tmp: seq[Rune] = @[]
for r in runes(s):
if isComb(r): tmp.insert(r, tmp.high)
else: tmp.add(r)
for i in countdown(tmp.high, 0):
result.add(toUtf8(tmp[i]))
for str in ["Reverse This!", "as⃝df̅"]:
echo "Original string: ", str
echo "Reversed: ", reversed(str)
echo "UniReversed: ", uniReversed(str)
echo "UniReversedPreserving: ", uniReversedPreserving(str)

View file

@ -0,0 +1 @@
reverse

View file

@ -0,0 +1 @@
<# 显示 指定 变量 反转顺序 字串>集装箱|猫坐在垫子</#>

View file

@ -0,0 +1 @@
<# 보이십 할당하 변물건 열거꾸 문자그>컨테이너|고양이가 매트 위에 앉아</#>

View file

@ -0,0 +1 @@
<@ SAYLETVARREVLIT>集装箱|猫坐在垫子</@>

View file

@ -0,0 +1 @@
?reverse("asdf")

View file

@ -0,0 +1,19 @@
function unicode_reverse(string utf8)
sequence utf32 = utf8_to_utf32(utf8)
integer ch
-- the assumption is made that <char><comb1><comb2>
-- and <char><comb2><comb1> etc would work the same.
for i=1 to length(utf32) do
ch = utf32[i]
if (ch>=0x300 and ch<=0x36f)
or (ch>=0x1dc0 and ch<=0x1dff)
or (ch>=0x20d0 and ch<=0x20ff)
or (ch>=0xfe20 and ch<=0xfe2f) then
utf32[i] = utf32[i-1]
utf32[i-1] = ch
end if
end for
utf32 = reverse(utf32)
utf8 = utf32_to_utf8(utf32)
return utf8
end function

View file

@ -0,0 +1,3 @@
cStr = "asdf" cStr2 = ""
for x = len(cStr) to 1 step -1 cStr2 += cStr[x] next
See cStr2 # fdsa

View file

@ -0,0 +1,3 @@
import <Utilities/Sequence.sl>;
main(args(2)) := Sequence::reverse(args[1]);

View file

@ -0,0 +1,6 @@
reverse<T> : T(1) -> T(1);
reverse(list(1))[i] :=
let
range := - ((1 ... size(list)) - (size(list) + 1));
in
list[i] foreach i within range;

View file

@ -0,0 +1,2 @@
"asdf".reverse; # fdsa
"résumé niño".reverse; # oñin émusér

View file

@ -0,0 +1,5 @@
func reverseString(s: String) -> String {
return String(s.characters.reverse())
}
print(reverseString("asdf"))
print(reverseString("as⃝df̅"))

View file

@ -0,0 +1,5 @@
func reverseString(s: String) -> String {
return String(reverse(s))
}
println(reverseString("asdf"))
println(reverseString("as⃝df̅"))

View file

@ -0,0 +1 @@
(rev "asdf")

View file

@ -0,0 +1,4 @@
; the @rev operator reverses strings and arrays
@rev "abc" ; returns "cba"
; or the same thing using a pointer expression
!~r "abc"

View file

@ -0,0 +1 @@
def reverse_string: explode | reverse | implode;