let A = "ACGTACGTACGT" and B = "ACTAGCTACTGT" in let LCS A B = let rec down [] _ _ = nil || down (Ach.As) B L = let rec across [] _ _ _ = nil || -- NW N across (Bch.Bs) West NWest North = -- W here (if Ach=Bch then (1+hd NWest) else max (hd West) (hd North) ) . across Bs (tl West) (tl NWest) (tl North) and thisrow = 0 . across B thisrow (hd L) (tl(hd L)) in thisrow . down As B (tl L) and L = (0. map (\x.0) B) -- [ [0; 0; 0; ...; 0] ; . down A B L -- [0; ... ] ; -- ... ] in last(last L) in "LCS(" @ A @ ", " @ B @ ") = " @ itos( LCS A B ) --\fB O(|A|*|B|) Longest Common Subsequence Algorithm. \fP