March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -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);
}

View file

@ -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")