RosettaCodeData/Task/Longest-common-subsequence/Logo/longest-common-subsequence.logo

10 lines
263 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
to longest :s :t
output ifelse greater? count :s count :t [:s] [:t]
end
to lcs :s :t
if empty? :s [output :s]
if empty? :t [output :t]
if equal? first :s first :t [output combine first :s lcs bf :s bf :t]
output longest lcs :s bf :t lcs bf :s :t
end