langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
11
Task/Multisplit/Perl-6/multisplit.pl6
Normal file
11
Task/Multisplit/Perl-6/multisplit.pl6
Normal 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()";
|
||||
}
|
||||
17
Task/Multisplit/Pike/multisplit.pike
Normal file
17
Task/Multisplit/Pike/multisplit.pike
Normal 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"})
|
||||
9
Task/Multisplit/Run-BASIC/multisplit.run
Normal file
9
Task/Multisplit/Run-BASIC/multisplit.run
Normal 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
|
||||
11
Task/Multisplit/TXR/multisplit.txr
Normal file
11
Task/Multisplit/TXR/multisplit.txr
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue