Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
43
Task/String-matching/Lambdatalk/string-matching.lambdatalk
Normal file
43
Task/String-matching/Lambdatalk/string-matching.lambdatalk
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{def S.in
|
||||
{def S.in.r {lambda {:c :w :i :n}
|
||||
{if {= :i :n}
|
||||
then -1
|
||||
else {if {W.equal? :c {W.get :i :w}}
|
||||
then :i
|
||||
else {S.in.r :c :w {+ :i 1} :n}}}}}
|
||||
{lambda {:c :w}
|
||||
{S.in.r :c :w 0 {W.length :w}}}}
|
||||
-> S.in
|
||||
|
||||
|
||||
|
||||
{def startswith
|
||||
{lambda {:w1 :w2}
|
||||
{= {S.in _ {S.replace :w2 by _ in :w1}} 0}}}
|
||||
-> startswith
|
||||
|
||||
{def endswith
|
||||
{lambda {:w1 :w2}
|
||||
{= {S.in _ {S.replace :w2 by _ in :w1}}
|
||||
{- {W.length :w1} {W.length :w2}}}}}
|
||||
-> endswith
|
||||
|
||||
{def isin
|
||||
{lambda {:w1 :w2}
|
||||
{S.in _ {S.replace :w2 by _ in :w1}}}}
|
||||
-> isin
|
||||
|
||||
{startswith nabuchodonosor nabu}
|
||||
-> true
|
||||
{startswith nabuchodonosor abu}
|
||||
-> false
|
||||
|
||||
{endswith nabuchodonosor sor}
|
||||
-> true
|
||||
{endswith nabuchodonosor oso}
|
||||
-> false
|
||||
|
||||
{isin nabuchodonosor oso}
|
||||
-> 10 // is in at 10
|
||||
{isin nabuchodonosor xyz}
|
||||
-> -1 // is not in
|
||||
Loading…
Add table
Add a link
Reference in a new issue