String matching: Difference between revisions
Content added Content deleted
(→{{header|Lang5}}: add.) |
(→{{header|Lang5}}: rev.) |
||
Line 823: | Line 823: | ||
=={{header|Lang5}}== |
=={{header|Lang5}}== |
||
<lang lang5>: bi* '_ set dip _ execute ; : bi@ dup bi* ; |
<lang lang5>: bi* '_ set dip _ execute ; : bi@ dup bi* ; |
||
: comb "" split ; : concat "" join ; |
: comb "" split ; : concat "" join ; : dip swap '_ set execute _ ; |
||
: |
: first 0 extract swap drop ; : flip comb reverse concat ; |
||
: contains |
: contains |
||
"comb length" bi@ swap 4 3 _roll 2 compress reshape # create a matrix. |
"comb length" bi@ swap 4 3 _roll 2 compress reshape # create a matrix. |
||
shape dup first iota swap reshape -1 transpose first -rot # position. |
|||
: concat.(*) concat ; |
|||
: concat.(*) concat ; |
|||
'concat "'concat. apply" bi* eq 1 1 compress index collapse |
|||
length if expand drop else drop 0 then |
length if expand drop else drop 0 then |
||
extract swap drop ; # result: positon. |
|||
: end-with 'flip bi@ start-with ; |
: end-with 'flip bi@ start-with ; |
||
: start-with 'comb bi@ length rot swap iota subscript 'concat bi@ eq ; |
: start-with 'comb bi@ length rot swap iota subscript 'concat bi@ eq ; |
||
"rosettacode" "rosetta" start-with . # 1 |
"rosettacode" "rosetta" start-with . # 1 |
||
"rosettacode" "taco" contains . # |
"rosettacode" "taco" contains . # 5 |
||
"rosettacode" "ocat" contains . # 0 |
"rosettacode" "ocat" contains . # 0 |
||
"rosettacode" "edoc" end-with . # 0 |
"rosettacode" "edoc" end-with . # 0 |
||
"rosettacode" "code" contains . # 7</lang> |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |