From f7820f9b51ee4fcddab57b54d6fca6c14581adab Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 6 Oct 2009 10:46:09 -0500 Subject: [PATCH] give cords a shot of red bull --- basis/cords/cords.factor | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/basis/cords/cords.factor b/basis/cords/cords.factor index 915744491f..a50de60c45 100644 --- a/basis/cords/cords.factor +++ b/basis/cords/cords.factor @@ -6,35 +6,37 @@ IN: cords > length ] [ second>> length ] bi + ; + [ first>> length ] [ second>> length ] bi + ; inline -M: simple-cord virtual-seq first>> ; +M: simple-cord virtual-seq first>> ; inline M: simple-cord virtual@ 2dup first>> length < - [ first>> ] [ [ first>> length - ] [ second>> ] bi ] if ; + [ first>> ] [ [ first>> length - ] [ second>> ] bi ] if ; inline -TUPLE: multi-cord count seqs ; +TUPLE: multi-cord + { count read-only } { seqs read-only } ; -M: multi-cord length count>> ; +M: multi-cord length count>> ; inline M: multi-cord virtual@ dupd seqs>> [ first <=> ] with search nip - [ first - ] [ second ] bi ; + [ first - ] [ second ] bi ; inline M: multi-cord virtual-seq - seqs>> [ f ] [ first second ] if-empty ; + seqs>> [ f ] [ first second ] if-empty ; inline : ( seqs -- cord ) dup length 2 = [ first2 simple-cord boa ] [ [ 0 [ length + ] accumulate ] keep zip multi-cord boa - ] if ; + ] if ; inline PRIVATE> @@ -52,7 +54,7 @@ INSTANCE: multi-cord virtual-sequence { [ over cord? ] [ [ seqs>> values ] dip suffix ] } { [ dup cord? ] [ seqs>> values swap prefix ] } [ 2array ] - } cond ; + } cond ; inline : cord-concat ( seqs -- cord ) { @@ -67,4 +69,4 @@ INSTANCE: multi-cord virtual-sequence } cond ] map concat ] - } cond ; + } cond ; inline