Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
11
Task/Substring-Top-and-tail/Ada/substring-top-and-tail-1.adb
Normal file
11
Task/Substring-Top-and-tail/Ada/substring-top-and-tail-1.adb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Remove_Characters is
|
||||
S: String := "upraisers";
|
||||
use Ada.Text_IO;
|
||||
begin
|
||||
Put_Line("Full String: """ & S & """");
|
||||
Put_Line("Without_First: """ & S(S'First+1 .. S'Last) & """");
|
||||
Put_Line("Without_Last: """ & S(S'First .. S'Last-1) & """");
|
||||
Put_Line("Without_Both: """ & S(S'First+1 .. S'Last-1) & """");
|
||||
end Remove_Characters;
|
||||
33
Task/Substring-Top-and-tail/Ada/substring-top-and-tail-2.adb
Normal file
33
Task/Substring-Top-and-tail/Ada/substring-top-and-tail-2.adb
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
with Ada.Text_IO;
|
||||
with Ada.Strings.UTF_Encoding.Wide_Strings;
|
||||
|
||||
procedure Remove_Characters
|
||||
is
|
||||
use Ada.Text_IO;
|
||||
use Ada.Strings.UTF_Encoding;
|
||||
use Ada.Strings.UTF_Encoding.Wide_Strings;
|
||||
|
||||
S : String := "upraisers";
|
||||
U : Wide_String := Decode (UTF_8_String'(S));
|
||||
|
||||
function To_String (X : Wide_String)return String
|
||||
is
|
||||
begin
|
||||
return String (UTF_8_String'(Encode (X)));
|
||||
end To_String;
|
||||
|
||||
begin
|
||||
Put_Line
|
||||
(To_String
|
||||
("Full String: """ & U & """"));
|
||||
Put_Line
|
||||
(To_String
|
||||
("Without_First: """ & U (U'First + 1 .. U'Last) & """"));
|
||||
Put_Line
|
||||
(To_String
|
||||
("Without_Last: """ & U (U'First .. U'Last - 1) & """"));
|
||||
Put_Line
|
||||
(To_String
|
||||
("Without_Both: """ & U (U'First + 1 .. U'Last - 1) & """"));
|
||||
|
||||
end Remove_Characters;
|
||||
17
Task/Substring-Top-and-tail/COBOL/substring-top-and-tail.cob
Normal file
17
Task/Substring-Top-and-tail/COBOL/substring-top-and-tail.cob
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
identification division.
|
||||
program-id. toptail.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 data-field.
|
||||
05 value "[this is a test]".
|
||||
|
||||
procedure division.
|
||||
sample-main.
|
||||
display data-field
|
||||
*> Using reference modification, which is (start-position:length)
|
||||
display data-field(2:)
|
||||
display data-field(1:length of data-field - 1)
|
||||
display data-field(2:length of data-field - 2)
|
||||
goback.
|
||||
end program toptail.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
str = "abcde"
|
||||
# String with first character removed
|
||||
str[1..] #=> "bcde"
|
||||
str.lchop #=> "bcde"
|
||||
|
||||
# String with last character removed
|
||||
str[..-2] #=> "abcd"
|
||||
str.rchop #=> "abcd"
|
||||
|
||||
# String with both the first and last characters removed
|
||||
str[1..-2] #=> "bcd"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(let ((string "top and tail"))
|
||||
(substring string 1) ;=> "op and tail"
|
||||
(substring string 0 (1- (length string))) ;=> "top and tai"
|
||||
(substring string 1 (1- (length string)))) ;=> "op and tai"
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
function strip_first(sequence s)
|
||||
return s[2..$]
|
||||
end function
|
||||
|
||||
function strip_last(sequence s)
|
||||
return s[1..$-1]
|
||||
end function
|
||||
|
||||
function strip_both(sequence s)
|
||||
return s[2..$-1]
|
||||
end function
|
||||
|
||||
puts(1, strip_first("knight")) -- strip first character
|
||||
puts(1, strip_last("write")) -- strip last character
|
||||
puts(1, strip_both("brooms")) -- strip both first and last characters
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
-->
|
||||
<span style="color: #008080;">constant</span> <span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"(test)"</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">2</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">2</span><span style="color: #0000FF;">]</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">2</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">2</span><span style="color: #0000FF;">]</span>
|
||||
<!--
|
||||
constant s = utf8_to_utf32("(test)")
|
||||
?utf32_to_utf8(s[2..-1])
|
||||
?utf32_to_utf8(s[1..-2])
|
||||
?utf32_to_utf8(s[2..-2])
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
require "uchar"
|
||||
|
||||
local a = uchar.of("Beyoncé")
|
||||
local b = a:sub(2)
|
||||
local c = a:sub(1, -2)
|
||||
local d = c:sub(2)
|
||||
for {a, b, c, d} as e do print(e) end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$string = "top and tail"
|
||||
$string
|
||||
$string.Substring(1)
|
||||
$string.Substring(0, $string.Length - 1)
|
||||
$string.Substring(1, $string.Length - 2)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$string = "top and tail"
|
||||
$string
|
||||
$string[1..($string.Length - 1)] -join ""
|
||||
$string[0..($string.Length - 2)] -join ""
|
||||
$string[1..($string.Length - 2)] -join ""
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
substring "hello" 1 4
|
||||
ell
|
||||
|
||||
rest "hello"
|
||||
ello
|
||||
|
||||
before-last "world"
|
||||
worl
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
fn main() {
|
||||
words := "(The V Programming Language)"
|
||||
println("${words.substr(1, words.len)}") // remove first character
|
||||
println("${words.substr(0, words.len - 1)}") // remove last character
|
||||
println("${words.runes()[1..words.len - 1].string()}") // remove first and last characters
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Function TopNTail(s,mode)
|
||||
Select Case mode
|
||||
Case "top"
|
||||
TopNTail = Mid(s,2,Len(s)-1)
|
||||
Case "tail"
|
||||
TopNTail = Mid(s,1,Len(s)-1)
|
||||
Case "both"
|
||||
TopNTail = Mid(s,2,Len(s)-2)
|
||||
End Select
|
||||
End Function
|
||||
|
||||
WScript.Echo "Top: UPRAISERS = " & TopNTail("UPRAISERS","top")
|
||||
WScript.Echo "Tail: UPRAISERS = " & TopNTail("UPRAISERS","tail")
|
||||
WScript.Echo "Both: UPRAISERS = " & TopNTail("UPRAISERS","both")
|
||||
Loading…
Add table
Add a link
Reference in a new issue