Anonymous user
String matching: Difference between revisions
→{{header|Lang5}}: rev. rotation of string
(→{{header|Lang5}}: rev.) |
(→{{header|Lang5}}: rev. rotation of string) |
||
Line 822:
=={{header|Lang5}}==
<lang lang5>: 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
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 ;
|