Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
7
Task/Reverse-a-string/Agda/reverse-a-string.agda
Normal file
7
Task/Reverse-a-string/Agda/reverse-a-string.agda
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
module reverse_string where
|
||||
|
||||
open import Data.String
|
||||
open import Data.List
|
||||
|
||||
reverse_string : String → String
|
||||
reverse_string s = fromList (reverse (toList s))
|
||||
|
|
@ -1,12 +1,5 @@
|
|||
get reverse_string("as⃝df̅")
|
||||
reverseString("Hello World!")
|
||||
|
||||
on reverse_string(str)
|
||||
set old_delim to (get AppleScript's text item delimiters)
|
||||
set AppleScript's text item delimiters to ""
|
||||
|
||||
set temp to (reverse of text items of str)
|
||||
set temp to (text items of temp) as Unicode text
|
||||
|
||||
set AppleScript's text item delimiters to old_delim
|
||||
return temp
|
||||
end reverse_string
|
||||
on reverseString(str)
|
||||
reverse of characters of str as string
|
||||
end reverseString
|
||||
|
|
|
|||
|
|
@ -1,14 +1 @@
|
|||
v The string to reverse. The row to copy to.
|
||||
| | The actual copying happens here.
|
||||
| | | Increment column to write to.
|
||||
| | | | Store column #.
|
||||
v v v v v
|
||||
> "reverse me" 3 10p >10g 4 p 10g1+ 10pv
|
||||
^ ^ |: <
|
||||
First column --| | @ ^
|
||||
to write to. | ^ Get the address
|
||||
All calls to 10 | to copy the next
|
||||
involve saving or | character to.
|
||||
reading the End when stack is empty or
|
||||
column to write explicit zero is reached.
|
||||
to.
|
||||
55+~>:48>*#8\#4`#:!#<#~_$>:#,_@
|
||||
|
|
|
|||
18
Task/Reverse-a-string/Forth/reverse-a-string-2.fth
Normal file
18
Task/Reverse-a-string/Forth/reverse-a-string-2.fth
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
\ reverse a counted string using the stack
|
||||
\ Method: Read the input string character by character onto the parameter stack
|
||||
\ Then write the character back into the same string from the stack
|
||||
|
||||
create mystring ," ABCDEFGHIJKLMNOPQRSTUVWXYZ987654321" \ this is a counted string
|
||||
|
||||
: pushstr ( str -- char[1].. char[n]) \ read the contents of STR onto the stack
|
||||
count bounds do I c@ loop ;
|
||||
|
||||
: popstr ( char[1].. char[n] str -- ) \ read chars off stack into str
|
||||
count bounds do I c! loop ;
|
||||
|
||||
: reverse ( str -- ) \ create the reverse function with the factored words
|
||||
dup >r \ put a copy of the string addr on return stack
|
||||
pushstr \ push the characters onto the parameter stack
|
||||
r> popstr ; \ get back our copy of the string addr and pop the characters into it
|
||||
|
||||
\ test in the Forth console
|
||||
|
|
@ -10,7 +10,6 @@ function reverseStr(s) {
|
|||
}
|
||||
|
||||
//fast method using while loop (faster with long strings in some browsers when compared with for loop)
|
||||
|
||||
function reverseStr(s) {
|
||||
var i = s.length, o = '';
|
||||
while (i--) o += s[i];
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
julia> join(reverse(collect(graphemes("nöel"))))
|
||||
"leön"
|
||||
julia> join(reverse(collect(graphemes("as⃝df̅"))))
|
||||
"f̅ds⃝a"
|
||||
|
|
|
|||
1
Task/Reverse-a-string/RapidQ/reverse-a-string.rapidq
Normal file
1
Task/Reverse-a-string/RapidQ/reverse-a-string.rapidq
Normal file
|
|
@ -0,0 +1 @@
|
|||
print reverse$("This is a test")
|
||||
12
Task/Reverse-a-string/Rust/reverse-a-string.rust
Normal file
12
Task/Reverse-a-string/Rust/reverse-a-string.rust
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
extern crate unicode_segmentation;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
fn main() {
|
||||
let s = "一二三四五六七八九十";
|
||||
let s2 = "as⃝df̅";
|
||||
let reversed: String = s.chars().rev().collect();
|
||||
let reversed2: String = UnicodeSegmentation::graphemes(s2, true)
|
||||
.rev().collect();
|
||||
println!("{}", reversed);
|
||||
println!("{}", reversed2);
|
||||
}
|
||||
1
Task/Reverse-a-string/Self/reverse-a-string.self
Normal file
1
Task/Reverse-a-string/Self/reverse-a-string.self
Normal file
|
|
@ -0,0 +1 @@
|
|||
'asdf' copyMutable reverse
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
:"ASDF"→Str1
|
||||
:
|
||||
:" "→Str0
|
||||
:length(Str1)→B
|
||||
:For(A,B,1,-1)
|
||||
:Str0+sub(Str1,A,1)→Str0
|
||||
:Str1
|
||||
:For(I,1,length(Ans)-1
|
||||
:sub(Ans,2I,1)+Ans
|
||||
:End
|
||||
:sub(Str0,2,B)→Str0
|
||||
:sub(Ans,1,I→Str1
|
||||
|
|
|
|||
3
Task/Reverse-a-string/UNIX-Shell/reverse-a-string-2.sh
Normal file
3
Task/Reverse-a-string/UNIX-Shell/reverse-a-string-2.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
str='i43go1342iu 23iu4o 23iu14i324y 2i13'
|
||||
rev <<< "$str"
|
||||
#rev is not built-in function, though is in /usr/bin/rev
|
||||
Loading…
Add table
Add a link
Reference in a new issue