Jump to content

String matching: Difference between revisions

Line 823:
=={{header|Lang5}}==
<lang lang5>: bi* '_ set dip _ execute ; : bi@ dup bi* ;
: comb "" split ; : concat "" join ; : dip swap '_ set execute _ ;
: dipfirst swap0 '_extract set executeswap _drop ; : flip comb reverse concat ;
 
: contains
"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. apply" bi(*) eq [1] indexconcat collapse;
'concat "'concat. apply" bi* eq 1 1 compress index collapse
length if expand drop else drop 0 then ; # result.
extract swap drop ; # result: positon.
: 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 . # 45
"rosettacode" "ocat" contains . # 0
"rosettacode" "edoc" end-with . # 0</lang>
"rosettacode" "code" contains . # 7</lang>
 
=={{header|Liberty BASIC}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.