Longest common subsequence: Difference between revisions
Content added Content deleted
No edit summary |
(Logo) |
||
Line 314: | Line 314: | ||
return sb.reverse().toString(); |
return sb.reverse().toString(); |
||
}</lang> |
}</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}}== |
=={{header|OCaml}}== |