Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Substring/Lang5/substring.lang5
Normal file
20
Task/Substring/Lang5/substring.lang5
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
: cr "\n". ; [] '__A set : dip swap __A swap 1 compress append '__A set execute __A
|
||||
-1 extract nip ; : nip swap drop ; : tuck swap over ; : -rot rot rot ; : 0= 0 == ; : 1+ 1 + ;
|
||||
: 2dip swap 'dip dip ; : 2drop drop drop ; : |a,b> over - iota + ; : bi* 'dip dip execute ; : bi@ dup bi* ;
|
||||
: comb "" split ; : concat "" join ; : empty? length 0= ; : tail over lensize |a,b> subscript ;
|
||||
: lensize length nip ; : while do 'dup dip 'execute 2dip rot if dup 2dip else break then loop 2drop ;
|
||||
|
||||
: <substr> comb -rot over + |a,b> subscript concat ;
|
||||
: str-tail tail concat ;
|
||||
: str-index
|
||||
: 2streq 2dup over lensize iota subscript eq '* reduce ;
|
||||
swap 'comb bi@ length -rot 0 -rot
|
||||
"2dup 'lensize bi@ <="
|
||||
"2streq if 0 reshape else '1+ 2dip 0 extract drop then"
|
||||
while empty? if 2drop tuck == if drop -1 then else 4 ndrop -1 then ;
|
||||
|
||||
'abcdefgh 'str set 2 'n set 3 'm set
|
||||
n m str <substr>
|
||||
str comb n str-tail
|
||||
str "d" str-index m str <substr>
|
||||
str "de" str-index m str <substr>
|
||||
Loading…
Add table
Add a link
Reference in a new issue