September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,27 @@
* Substring/Top and tail 04/03/2017
SUBSTRTT CSECT
USING SUBSTRTT,R13 base register
B 72(R15) skip savearea
DC 17F'0' savearea
STM R14,R12,12(R13) save previous context
ST R13,4(R15) link backward
ST R15,8(R13) link forward
LR R13,R15 set addressability
*
XPRNT S8,L'S8 print s8
MVC S7,S8+1 s7=substr(s8,2,7)
XPRNT S7,L'S7 print s7
MVC S7,S8 s7=substr(s8,1,7)
XPRNT S7,L'S7 print s7
MVC S6,S8+1 s6=substr(s8,2,6)
XPRNT S6,L'S6 print s6
*
L R13,4(0,R13) epilog
LM R14,R12,12(R13) restore previous context
XR R15,R15 rc=0
BR R14 exit
S8 DC CL8'12345678'
S7 DS CL7
S6 DS CL6
YREGS
END SUBSTRTT

View 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;

View file

@ -0,0 +1,8 @@
10 REM STRING SLICING EXAMPLE
20 LET S$="KNIGHTS"
30 REM WITH FIRST CHARACTER REMOVED:
40 PRINT S$(2 TO )
50 REM WITH LAST CHARACTER REMOVED:
60 PRINT S$( TO LEN S$-1)
70 REM WITH BOTH REMOVED:
80 PRINT S$(2 TO LEN S$-1)

View file

@ -0,0 +1,2 @@
main :: IO ()
main = mapM_ print $ [tail, init, init . tail] <*> ["knights"]

View file

@ -0,0 +1,7 @@
// version 1.0.6
fun main(args: Array<String>) {
val s = "Rosetta"
println(s.drop(1))
println(s.dropLast(1))
println(s.drop(1).dropLast(1))
}

View file

@ -1,6 +0,0 @@
var s = "The quick μ brown fox"
echo(s.substr(1))
echo(s.substr(0,s.len-2))
echo(s.substr(1,s.len-2))
# using slices
echo(s[1 .. -2])

View file

@ -1,8 +0,0 @@
say substr('knight', 1); # strip first character - sub
say 'knight'.substr(1); # strip first character - method
say substr('socks', 0, -1); # strip last character - sub
say 'socks'.substr( 0, -1); # strip last character - method
say substr('brooms', 1, -1); # strip both first and last characters - sub
say 'brooms'.substr(1, -1); # strip both first and last characters - method

View file

@ -1,5 +0,0 @@
my $string = 'ouch';
say $string.chop; # ouc - does not modify original $string
say $string; # ouch
say $string.p5chop; # h - returns the character chopped off and modifies $string
say $string; # ouc

View file

@ -0,0 +1,3 @@
"Smiles"[1,*] //-->miles
"Smiles"[0,-1] //-->Smile
"Smiles"[1,-1] //-->mile