langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,11 @@
sub multisplit($str, @seps) { $str.split(/ ||@seps /, :all) }
my @chunks = multisplit( 'a!===b=!=c==d', < == != = > );
# Print the strings.
say @chunks».Str.perl;
# Print the positions of the separators.
for grep Match, @chunks -> $s {
say " $s from $s.from() to $s.to()";
}

View file

@ -0,0 +1,17 @@
string input = "a!===b=!=c";
array sep = ({"==", "!=", "=" });
array result = replace(input, sep, `+("\0", sep[*], "\0"))/"\0";
result;
Result: ({ "a", "!=", "", "==", "b", "=", "", "!=", "c" })
int pos = 0;
foreach(result; int index; string data)
{
if ((<"==", "!=", "=">)[data])
result[index] = ({ data, pos });
pos+=sizeof(data);
}
result;
Result: ({"a", ({"!=", 1}), "", ({"==", 3}), "b", ({"=", 6}), "", ({"!=", 7}), "c"})

View file

@ -0,0 +1,9 @@
str$ = "a!===b=!=c"
sep$ = "=== != =! b =!="
while word$(sep$,i+1," ") <> ""
i = i + 1
theSep$ = word$(sep$,i," ")
split$ = word$(str$,1,theSep$)
print i;" ";split$;" Sep By: ";theSep$
wend

View file

@ -0,0 +1,11 @@
@(next :args)
@(coll :gap 0)@(choose :shortest tok)@\
@tok@{sep /==/}@\
@(or)@\
@tok@{sep /!=/}@\
@(or)@\
@tok@{sep /=/}@\
@(end)@(end)@tail
@(output)
@(rep)"@tok" {@sep} @(end)"@tail"
@(end)