Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/String-matching/Lang5/string-matching.lang5
Normal file
20
Task/String-matching/Lang5/string-matching.lang5
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
: 2array 2 compress ; : bi* '_ set dip _ execute ; : bi@ dup bi* ;
|
||||
: comb "" split ; : concat "" join ; : dip swap '_ set execute _ ;
|
||||
: first 0 extract swap drop ; : flip comb reverse concat ;
|
||||
|
||||
: contains
|
||||
swap 'comb bi@ length do # create a matrix.
|
||||
1 - "dup 1 1 compress rotate" dip dup 0 == if break then
|
||||
loop drop length compress swap drop
|
||||
"length 1 -" bi@ rot 0 0 "'2array dip" '2array bi* swap 2array slice reverse
|
||||
: concat.(*) concat ;
|
||||
'concat "'concat. apply" bi* eq 1 1 compress index collapse
|
||||
length if expand drop else drop 0 then ; # r: position.
|
||||
: end-with 'flip bi@ start-with ;
|
||||
: start-with 'comb bi@ length rot swap iota subscript 'concat bi@ eq ;
|
||||
|
||||
"rosettacode" "rosetta" start-with . # 1
|
||||
"rosettacode" "taco" contains . # 5
|
||||
"rosettacode" "ocat" contains . # 0
|
||||
"rosettacode" "edoc" end-with . # 0
|
||||
"rosettacode" "code" contains . # 7
|
||||
Loading…
Add table
Add a link
Reference in a new issue