Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Reverse-a-string/Turing/reverse-a-string-1.turing
Normal file
10
Task/Reverse-a-string/Turing/reverse-a-string-1.turing
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function reverse (s : string) : string
|
||||
var rs := ""
|
||||
for i : 0 .. length (s) - 1
|
||||
rs := rs + s (length (s) - i)
|
||||
end for
|
||||
result rs
|
||||
end reverse
|
||||
|
||||
put reverse ("iterative example")
|
||||
put reverse (reverse ("iterative example"))
|
||||
10
Task/Reverse-a-string/Turing/reverse-a-string-2.turing
Normal file
10
Task/Reverse-a-string/Turing/reverse-a-string-2.turing
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function reverse (s : string) : string
|
||||
if s = "" then
|
||||
result s
|
||||
else
|
||||
result reverse (s (2 .. *)) + s (1)
|
||||
end if
|
||||
end reverse
|
||||
|
||||
put reverse ("recursive example")
|
||||
put reverse (reverse ("recursive example"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue