Longest common subsequence: Difference between revisions

Logo
No edit summary
(Logo)
Line 314:
return sb.reverse().toString();
}</lang>
 
=={{header|Logo}}==
This implementation works on both words and lists.
<lang logo>
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
</lang>
 
=={{header|OCaml}}==
Anonymous user