18 lines
578 B
Text
18 lines
578 B
Text
{def lcs
|
|
{def lcs.rec
|
|
{lambda {:a :b :w}
|
|
{if {or {< {W.length :a} 2} {< {W.length :b} 2} }
|
|
then {W.rest :w}
|
|
else {if {W.equal? {W.first :a} {W.first :b}}
|
|
then {lcs.rec {W.rest :a} {W.rest :b} :w{W.first :a}}
|
|
else {let { {:x {lcs.rec :a {W.rest :b} :w}}
|
|
{:y {lcs.rec {W.rest :a} :b :w}}
|
|
} {if {> {W.length :x} {W.length :y}}
|
|
then :x
|
|
else :y} }}}}}
|
|
{lambda {:a :b}
|
|
{lcs.rec :a# :b# #}}}
|
|
-> lcs
|
|
|
|
{lcs testing123testing thisisatest}
|
|
-> tsitest // 23000ms
|