X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=basis%2Flcs%2Flcs.factor;h=aabd4bbafcd6e84d55d4dbb7e008e197b30ecf0d;hp=ab4fbd60bb9fdbdf2c7b2daa5ab7768f18b3a950;hb=3f3d57032bf29190e9bee12d168a4bce6d74653c;hpb=cd1bb8f4c8afba318249c7b756a45aa1c46ea51e diff --git a/basis/lcs/lcs.factor b/basis/lcs/lcs.factor index ab4fbd60bb..aabd4bbafc 100644 --- a/basis/lcs/lcs.factor +++ b/basis/lcs/lcs.factor @@ -5,18 +5,18 @@ IN: lcs ] with map ; @@ -25,7 +25,7 @@ IN: lcs [ [ + ] curry map ] with map ; :: run-lcs ( old new init step -- matrix ) - [let | matrix [ old length 1+ new length 1+ init call ] | + [let | matrix [ old length 1 + new length 1 + init call ] | old length [| i | new length [| j | i j matrix old new step loop-step ] each @@ -44,14 +44,14 @@ TUPLE: insert item ; TUPLE: trace-state old new table i j ; : old-nth ( state -- elt ) - [ i>> 1- ] [ old>> ] bi nth ; + [ i>> 1 - ] [ old>> ] bi nth ; : new-nth ( state -- elt ) - [ j>> 1- ] [ new>> ] bi nth ; + [ j>> 1 - ] [ new>> ] bi nth ; : top-beats-side? ( state -- ? ) - [ [ i>> ] [ j>> 1- ] [ table>> ] tri nth nth ] - [ [ i>> 1- ] [ j>> ] [ table>> ] tri nth nth ] bi > ; + [ [ i>> ] [ j>> 1 - ] [ table>> ] tri nth nth ] + [ [ i>> 1 - ] [ j>> ] [ table>> ] tri nth nth ] bi > ; : retained? ( state -- ? ) { @@ -61,7 +61,7 @@ TUPLE: trace-state old new table i j ; : do-retain ( state -- state ) dup old-nth retain boa , - [ 1- ] change-i [ 1- ] change-j ; + [ 1 - ] change-i [ 1 - ] change-j ; : inserted? ( state -- ? ) { @@ -70,7 +70,7 @@ TUPLE: trace-state old new table i j ; } 1&& ; : do-insert ( state -- state ) - dup new-nth insert boa , [ 1- ] change-j ; + dup new-nth insert boa , [ 1 - ] change-j ; : deleted? ( state -- ? ) { @@ -79,7 +79,7 @@ TUPLE: trace-state old new table i j ; } 1&& ; : do-delete ( state -- state ) - dup old-nth delete boa , [ 1- ] change-i ; + dup old-nth delete boa , [ 1 - ] change-i ; : (trace-diff) ( state -- ) { @@ -90,7 +90,7 @@ TUPLE: trace-state old new table i j ; } cond ; : trace-diff ( old new table -- diff ) - [ ] [ first length 1- ] [ length 1- ] tri trace-state boa + [ ] [ first length 1 - ] [ length 1 - ] tri trace-state boa [ (trace-diff) ] { } make reverse ; PRIVATE>