Handbook
Glossary
lcs ( seq1 seq2 -- lcs )
LCS, diffing and distance
Next:
lcs-diff ( old new -- diff )
Vocabulary
lcs
Inputs
seq1
a
sequence
seq2
a
sequence
Outputs
lcs
a longest common subsequence
Word description
Given two sequences, calculates a longest common subsequence between them. Note two things: this is only one of the many possible LCSs, and the LCS may not be contiguous.
Definition
USING:
accessors
kernel
sequences
;
IN:
lcs
:
lcs
( seq1 seq2 -- lcs )
[
lcs-diff
[
retain?
]
filter
]
keep
[
item>>
]
swap
map-as
;