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

10 lines
263 B
Plaintext

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