September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,13 +0,0 @@
|
|||
PROC reverse = (REF STRING s)VOID:
|
||||
FOR i TO UPB s OVER 2 DO
|
||||
CHAR c = s[i];
|
||||
s[i] := s[UPB s - i + 1];
|
||||
s[UPB s - i + 1] := c
|
||||
OD;
|
||||
|
||||
main:
|
||||
(
|
||||
STRING text := "Was it a cat I saw";
|
||||
reverse(text);
|
||||
print((text, new line))
|
||||
)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
⌽'asdf'
|
||||
fdsa
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
module reverse_string where
|
||||
|
||||
open import Data.String
|
||||
open import Data.List
|
||||
|
||||
reverse_string : String → String
|
||||
reverse_string s = fromList (reverse (toList s))
|
||||
|
|
@ -1,23 +1 @@
|
|||
text
|
||||
reverse(text s)
|
||||
{
|
||||
data b;
|
||||
integer i;
|
||||
|
||||
i = length(s);
|
||||
while (i) {
|
||||
i -= 1;
|
||||
b_insert(b, -1, s[i]);
|
||||
}
|
||||
|
||||
return b_string(b);
|
||||
}
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
o_text(reverse("Hello, World!"));
|
||||
o_byte('\n');
|
||||
|
||||
return 0;
|
||||
}
|
||||
o_(b_reverse(b_draft("Hello, World!")), "\n");
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
-- reverse1 :: [a] -> [a]
|
||||
on reverse1(xs)
|
||||
script rev
|
||||
on lambda(a, x)
|
||||
on |λ|(a, x)
|
||||
a & x
|
||||
end lambda
|
||||
end |λ|
|
||||
end script
|
||||
|
||||
if class of xs is text then
|
||||
|
|
@ -15,7 +15,6 @@ on reverse1(xs)
|
|||
end if
|
||||
end reverse1
|
||||
|
||||
|
||||
-- or the built-in reverse method for lists
|
||||
|
||||
-- reverse2 :: [a] -> [a]
|
||||
|
|
@ -28,22 +27,19 @@ on reverse2(xs)
|
|||
end reverse2
|
||||
|
||||
|
||||
|
||||
-- TESTING reverse1 and reverse2 with same string and list
|
||||
-- TESTING reverse1 and reverse2 with same string and list ---------------------------------------------------------------------------
|
||||
on run
|
||||
script test
|
||||
on lambda(f)
|
||||
on |λ|(f)
|
||||
map(f, ["Hello there !", {1, 2, 3, 4, 5}])
|
||||
end lambda
|
||||
end |λ|
|
||||
end script
|
||||
|
||||
map(test, [reverse1, reverse2])
|
||||
end run
|
||||
|
||||
|
||||
|
||||
|
||||
-- GENERIC LIBRARY FUNCTIONS
|
||||
-- GENERIC FUNCTIONS ---------------------------------------------------------------------------
|
||||
|
||||
-- foldr :: (a -> b -> a) -> a -> [b] -> a
|
||||
on foldr(f, startValue, xs)
|
||||
|
|
@ -51,7 +47,7 @@ on foldr(f, startValue, xs)
|
|||
set v to startValue
|
||||
set lng to length of xs
|
||||
repeat with i from lng to 1 by -1
|
||||
set v to lambda(v, item i of xs, i, xs)
|
||||
set v to |λ|(v, item i of xs, i, xs)
|
||||
end repeat
|
||||
return v
|
||||
end tell
|
||||
|
|
@ -63,7 +59,7 @@ on map(f, xs)
|
|||
set lng to length of xs
|
||||
set lst to {}
|
||||
repeat with i from 1 to lng
|
||||
set end of lst to lambda(item i of xs, i, xs)
|
||||
set end of lst to |λ|(item i of xs, i, xs)
|
||||
end repeat
|
||||
return lst
|
||||
end tell
|
||||
|
|
@ -76,7 +72,7 @@ on mReturn(f)
|
|||
f
|
||||
else
|
||||
script
|
||||
property lambda : f
|
||||
property |λ| : f
|
||||
end script
|
||||
end if
|
||||
end mReturn
|
||||
|
|
|
|||
6
Task/Reverse-a-string/BASIC/reverse-a-string-2.basic
Normal file
6
Task/Reverse-a-string/BASIC/reverse-a-string-2.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
10 INPUT S$
|
||||
20 LET T$=""
|
||||
30 FOR I=LEN S$ TO 1 STEP -1
|
||||
40 LET T$=T$+S$(I)
|
||||
50 NEXT I
|
||||
60 PRINT T$
|
||||
3
Task/Reverse-a-string/BaCon/reverse-a-string.bacon
Normal file
3
Task/Reverse-a-string/BaCon/reverse-a-string.bacon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
OPTION UTF8 TRUE
|
||||
s$ = "asdf"
|
||||
PRINT REVERSE$(s$)
|
||||
6
Task/Reverse-a-string/Crystal/reverse-a-string.crystal
Normal file
6
Task/Reverse-a-string/Crystal/reverse-a-string.crystal
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# version 0.21.1
|
||||
|
||||
strings = ["asdf", "as⃝df̅"]
|
||||
strings.each do |s|
|
||||
puts "#{s} -> #{s.reverse}"
|
||||
end
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
#import system.
|
||||
#import system'routines.
|
||||
#import extensions.
|
||||
import system'routines.
|
||||
import extensions.
|
||||
|
||||
#class(extension) extension
|
||||
extension extension
|
||||
{
|
||||
#method reversedLiteral
|
||||
= self toArray reverse summarize:(String new) literal.
|
||||
reversedLiteral
|
||||
= self toArray; sequenceReverse; summarize(String new); literal.
|
||||
}
|
||||
|
||||
#symbol program =
|
||||
program =
|
||||
[
|
||||
console writeLine:("Hello World" reversedLiteral).
|
||||
console printLine("Hello World" reversedLiteral).
|
||||
].
|
||||
|
|
|
|||
1
Task/Reverse-a-string/Futhark/reverse-a-string.futhark
Normal file
1
Task/Reverse-a-string/Futhark/reverse-a-string.futhark
Normal file
|
|
@ -0,0 +1 @@
|
|||
fun main(s: []i32) = s[::-1]
|
||||
12
Task/Reverse-a-string/Gambas/reverse-a-string.gambas
Normal file
12
Task/Reverse-a-string/Gambas/reverse-a-string.gambas
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Public Sub Main()
|
||||
Dim sString As String = "asdf"
|
||||
Dim sOutput As String
|
||||
Dim siCount As Short
|
||||
|
||||
For siCount = Len(sString) DownTo 1
|
||||
sOutput &= Mid(sString, siCount, 1)
|
||||
Next
|
||||
|
||||
Print sOutput
|
||||
|
||||
End
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
var
|
||||
str1 = "Reverse This!"
|
||||
|
||||
proc reverse(s: string): string =
|
||||
result = ""
|
||||
for i in countdown(high(str1), 0):
|
||||
result.add str1[i]
|
||||
|
||||
echo "Original string: ", str1, "\nReversed: ", reverse(str1)
|
||||
echo "Using inbuilt array reversal: ", reverse(str1)
|
||||
6
Task/Reverse-a-string/PlainTeX/reverse-a-string.tex
Normal file
6
Task/Reverse-a-string/PlainTeX/reverse-a-string.tex
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
\def\gobtoA#1\revA{}\def\gobtoB#1\revB{}
|
||||
\def\reverse#1{\reversei{}#1\revA\revB\revB\revB\revB\revB\revB\revB\revB\revA}
|
||||
\def\reversei#1#2#3#4#5#6#7#8#9{\gobtoB#9\revend\revB\reversei{#9#8#7#6#5#4#3#2#1}}
|
||||
\def\revend\revB\reversei#1#2\revA{\gobtoA#1}
|
||||
\reverse{Rosetta}
|
||||
\bye
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
accRev([H|T], A, R) :- accRev(T, [H|A], R).
|
||||
accRev([], A, A).
|
||||
|
||||
rev(L,R) :- accRev(L,[],R).
|
||||
|
|
@ -1 +0,0 @@
|
|||
<# 显示 指定 变量 反转顺序 字串>集装箱|猫坐在垫子</#>
|
||||
|
|
@ -1 +0,0 @@
|
|||
<# 보이십 할당하 변물건 열거꾸 문자그>컨테이너|고양이가 매트 위에 앉아</#>
|
||||
|
|
@ -1 +0,0 @@
|
|||
<@ SAYLETVARREVLIT>集装箱|猫坐在垫子</@>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
// rust 0.9
|
||||
let s = "一二三四五六七八九十";
|
||||
let reversed:~str = s.chars_rev().collect();
|
||||
|
|
@ -1 +0,0 @@
|
|||
let reversed:~str = "一二三四五六七八九十".chars_rev().collect();
|
||||
6
Task/Reverse-a-string/Stata/reverse-a-string.stata
Normal file
6
Task/Reverse-a-string/Stata/reverse-a-string.stata
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
. scalar s="ARS LONGA VITA BREVIS"
|
||||
. di strreverse(s)
|
||||
SIVERB ATIV AGNOL SRA
|
||||
. scalar s="Ἐν ἀρχῇ ἐποίησεν ὁ θεὸς τὸν οὐρανὸν καὶ τὴν γῆν"
|
||||
. di ustrreverse(s)
|
||||
νῆγ νὴτ ὶακ νὸναρὐο νὸτ ςὸεθ ὁ νεσηίοπἐ ῇχρἀ νἘ
|
||||
Loading…
Add table
Add a link
Reference in a new issue