]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: rename virtual-seq to virtual-exemplar
authorPhilipp Brüschweiler <blei42@gmail.com>
Fri, 6 Nov 2009 23:06:26 +0000 (00:06 +0100)
committerPhilipp Brüschweiler <blei42@gmail.com>
Fri, 6 Nov 2009 23:06:26 +0000 (00:06 +0100)
basis/circular/circular.factor
basis/columns/columns.factor
basis/cords/cords.factor
basis/math/blas/vectors/vectors.factor
basis/sequences/merged/merged-tests.factor
basis/sequences/merged/merged.factor
core/quotations/quotations.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor
extra/sequences/modified/modified.factor
extra/sequences/repeating/repeating.factor

index b3be4651cd627799269edbefa72ac168f97718ba..1c0efb1c36c15c104ba8a200e39f8028a3cd3a8d 100644 (file)
@@ -21,7 +21,7 @@ M: circular length seq>> length ;
 
 M: circular virtual@ circular-wrap seq>> ;
 
-M: circular virtual-seq seq>> ;
+M: circular virtual-exemplar seq>> ;
 
 : change-circular-start ( n circular -- )
     #! change start to (start + n) mod length
index 8f45dab8728c4e7ef153f94692dea47d0b2c36a1..8674217655c572e0bf977279d2fd3c9dc251882d 100644 (file)
@@ -8,7 +8,7 @@ TUPLE: column seq col ;
 
 C: <column> column
 
-M: column virtual-seq seq>> ;
+M: column virtual-exemplar seq>> ;
 M: column virtual@ [ col>> swap ] [ seq>> ] bi nth bounds-check ;
 M: column length seq>> length ;
 
index a50de60c45c4505fe4be2e81ff15fa486e053a23..ad17da96524718d87a599b9d535ad7c464b60e8f 100644 (file)
@@ -12,7 +12,7 @@ TUPLE: simple-cord
 M: simple-cord length
     [ first>> length ] [ second>> length ] bi + ; inline
 
-M: simple-cord virtual-seq first>> ; inline
+M: simple-cord virtual-exemplar first>> ; inline
 
 M: simple-cord virtual@
     2dup first>> length <
@@ -28,7 +28,7 @@ M: multi-cord virtual@
     seqs>> [ first <=> ] with search nip
     [ first - ] [ second ] bi ; inline
 
-M: multi-cord virtual-seq
+M: multi-cord virtual-exemplar
     seqs>> [ f ] [ first second ] if-empty ; inline
 
 : <cord> ( seqs -- cord )
index 8fa41c502613e33e03557de03fa421517da6a88b..083400224e98adf1b59aef23c44616624d512d74 100755 (executable)
@@ -117,7 +117,7 @@ M: blas-vector-base equal?
 
 M: blas-vector-base length
     length>> ;
-M: blas-vector-base virtual-seq
+M: blas-vector-base virtual-exemplar
     (blas-direct-array) ;
 M: blas-vector-base virtual@
     [ inc>> * ] [ nip (blas-direct-array) ] 2bi ;
index 1360bd8de1658d8e26dca1dcea54c101c99ba385..cbd4176bef40bb649acb01e1cfbdfc09a70c4de4 100644 (file)
@@ -17,3 +17,4 @@ IN: sequences.merged.tests
 [ 4 ] [ 4 { 1 2 } { 3 4 } { 5 6 } 3merge nth ] unit-test
 
 [ "" ] [ "abcdefg" "" 2merge ] unit-test
+[ "a1b2" ] [ "abc" "12" <2merged> "" like ] unit-test
index 0bc49976451e16e0f422492b41351c2e780f0c10..c14ccf2f20e0e46274b6f9d6def6a3895595b70b 100644 (file)
@@ -20,11 +20,12 @@ C: <merged> merged
     [ <3merged> ] 3keep 2drop like ;
 
 M: merged length
-    seqs>> [ [ length ] [ min ] map-reduce ] [ length ] bi * ;
+    seqs>> [ [ length ] [ min ] map-reduce ] [ length ] bi * ; inline
 
 M: merged virtual@ ( n seq -- n' seq' )
-    seqs>> [ length /mod ] [ nth-unsafe ] bi ;
+    seqs>> [ length /mod ] [ nth-unsafe ] bi ; inline
 
-M: merged virtual-seq ( merged -- seq ) [ ] { } map-as ;
+M: merged virtual-exemplar ( merged -- seq )
+    seqs>> [ f ] [ first ] if-empty ; inline
 
 INSTANCE: merged virtual-sequence
index f2b17b3f9da989da2b5e86d88a3a387401979072..2af94159f831ddb598a183ee0000e889187a9c87 100644 (file)
@@ -61,7 +61,7 @@ INSTANCE: curry immutable-sequence
 M: compose length
     [ first>> length ] [ second>> length ] bi + ;
 
-M: compose virtual-seq first>> ;
+M: compose virtual-exemplar first>> ;
 
 M: compose virtual@
     2dup first>> length < [
index e50614ac7369f10eb46882096c8defed43e71340..6d7ff241eff198c5c55541f374745741804d7203 100755 (executable)
@@ -1175,17 +1175,17 @@ HELP: partition
     }
 } ;
 
-HELP: virtual-seq
+HELP: virtual-exemplar
 { $values
      { "seq" sequence }
      { "seq'" sequence } }
-{ $description "Part of the virtual sequence protocol, this word is used to return an underlying array from which to look up a value at an index given by " { $link virtual@ } "." } ;
+{ $description "Part of the virtual sequence protocol, this word is used to return an exemplar of the underlying storage. This is used in words like " { $link new-sequence } "." } ;
 
 HELP: virtual@
 { $values
      { "n" integer } { "seq" sequence }
      { "n'" integer } { "seq'" sequence } }
-{ $description "Part of the sequence protocol, this word translates the input index " { $snippet "n" } " into an index into the underlying storage returned by " { $link virtual-seq } "." } ;
+{ $description "Part of the sequence protocol, this word translates the input index " { $snippet "n" } " into an index and the underlying storage this index points into." } ;
 
 HELP: 2map-reduce
 { $values
@@ -1397,9 +1397,9 @@ $nl
 ARTICLE: "virtual-sequences-protocol" "Virtual sequence protocol"
 "Virtual sequences must know their length:"
 { $subsections length }
-"The underlying sequence to look up a value in:"
-{ $subsections virtual-seq }
-"The index of the value in the underlying sequence:"
+"An exemplar of the underlying storage:"
+{ $subsections virtual-exemplar }
+"The index and the underlying storage where the value is located:"
 { $subsections virtual@ } ;
 
 ARTICLE: "virtual-sequences" "Virtual sequences"
index 1bcedb1d15825a9a8344068de76e7e508cfc2e16..fde5b5736db23936adef0e67fa2c0f89b921ace2 100755 (executable)
@@ -182,15 +182,15 @@ PRIVATE>
     2dup bounds-check? [ nth-unsafe ] [ 2drop f ] if ; inline
 
 MIXIN: virtual-sequence
-GENERIC: virtual-seq ( seq -- seq' )
+GENERIC: virtual-exemplar ( seq -- seq' )
 GENERIC: virtual@ ( n seq -- n' seq' )
 
 M: virtual-sequence nth virtual@ nth ; inline
 M: virtual-sequence set-nth virtual@ set-nth ; inline
 M: virtual-sequence nth-unsafe virtual@ nth-unsafe ; inline
 M: virtual-sequence set-nth-unsafe virtual@ set-nth-unsafe ; inline
-M: virtual-sequence like virtual-seq like ; inline
-M: virtual-sequence new-sequence virtual-seq new-sequence ; inline
+M: virtual-sequence like virtual-exemplar like ; inline
+M: virtual-sequence new-sequence virtual-exemplar new-sequence ; inline
 
 INSTANCE: virtual-sequence sequence
 
@@ -199,7 +199,7 @@ TUPLE: reversed { seq read-only } ;
 
 C: <reversed> reversed
 
-M: reversed virtual-seq seq>> ; inline
+M: reversed virtual-exemplar seq>> ; inline
 M: reversed virtual@ seq>> [ length swap - 1 - ] keep ; inline
 M: reversed length seq>> length ; inline
 
@@ -231,7 +231,7 @@ TUPLE: slice-error from to seq reason ;
     check-slice
     slice boa ; inline
 
-M: slice virtual-seq seq>> ; inline
+M: slice virtual-exemplar seq>> ; inline
 
 M: slice virtual@ [ from>> + ] [ seq>> ] bi ; inline
 
index 3fb87feaf8da17a5663009c9634232fe43ce8eb1..73fcc651bda4ef2de50b06751743de0de069c421 100644 (file)
@@ -21,7 +21,7 @@ TUPLE: 1modified < modified seq ;
 M: modified length seq>> length ;
 M: modified set-length seq>> set-length ;
 
-M: 1modified virtual-seq seq>> ;
+M: 1modified virtual-exemplar seq>> ;
 
 TUPLE: scaled < 1modified c ;
 C: <scaled> scaled
@@ -71,7 +71,8 @@ M: summed modified-set-nth ( elt n seq -- ) immutable ;
 M: summed set-length ( n seq -- )
     seqs>> [ set-length ] with each ;
 
-M: summed virtual-seq ( summed -- seq ) [ ] { } map-as ;
+M: summed virtual-exemplar ( summed -- seq )
+    seqs>> [ f ] [ first ] if-empty ;
 
 : <2summed> ( seq seq -- summed-seq ) 2array <summed> ;
 : <3summed> ( seq seq seq -- summed-seq ) 3array <summed> ;
index 77fddd551021305a9e52eebca18dc040d3422609..7157e3f025a059f1cc51f3de1061ac838bf43d12 100644 (file)
@@ -16,6 +16,6 @@ M: repeating set-length (>>len) ;
 
 M: repeating virtual@ ( n seq -- n' seq' ) circular>> ;
 
-M: repeating virtual-seq circular>> ;
+M: repeating virtual-exemplar circular>> ;
 
 INSTANCE: repeating virtual-sequence