March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -60,7 +60,7 @@ const(T)[] lcs(T)(in T[] xs, in T[] ys) pure /*nothrow*/ {
|
|||
.array;
|
||||
}
|
||||
|
||||
string lcsString(in string s1, in string s2) /*pure nothrow*/ {
|
||||
string lcsString(in string s1, in string s2) pure /*nothrow*/ {
|
||||
//return lcs(s1.representation, s2.representation).assumeChars;
|
||||
return cast(string)lcs(s1.representation, s2.representation);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,17 @@
|
|||
(hash-set! memo (cons xs ys) r)
|
||||
r)
|
||||
|
||||
(define (lcs sx sy)
|
||||
(define (lcs/list sx sy)
|
||||
(or (lookup sx sy)
|
||||
(store sx sy
|
||||
(match* (sx sy)
|
||||
[((cons x xs) (cons y ys))
|
||||
(if (equal? x y)
|
||||
(cons x (lcs xs ys))
|
||||
(longest (lcs sx ys) (lcs xs sy)))]
|
||||
(cons x (lcs/list xs ys))
|
||||
(longest (lcs/list sx ys) (lcs/list xs sy)))]
|
||||
[(_ _) '()]))))
|
||||
|
||||
(define (lcs sx sy)
|
||||
(list->string (lcs/list (string->list sx) (string->list sy))))
|
||||
|
||||
(lcs "thisisatest" "testing123testing")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue