]> gitweb.factorcode.org Git - factor.git/commitdiff
factor: Rename start -> subseq-start, start* -> subseq-start-from.
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 1 Jun 2017 19:45:54 +0000 (14:45 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 1 Jun 2017 19:45:54 +0000 (14:45 -0500)
I also removed aliases for start/end from interval-maps and interval-sets and added a comment. I don't think it's any less clear what's going on.

18 files changed:
basis/alien/libraries/finder/macosx/macosx.factor
basis/game/input/iokit/iokit.factor
basis/html/templates/fhtml/fhtml.factor
basis/interval-maps/interval-maps.factor
basis/interval-sets/interval-sets.factor
basis/mime/multipart/multipart.factor
basis/multiline/multiline.factor
basis/urls/urls.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor
core/splitting/splitting.factor
core/strings/strings-tests.factor
extra/combinators/extras/extras-tests.factor
extra/io/encodings/detect/detect.factor
extra/project-euler/047/047.factor
extra/rosetta-code/web-scraping/web-scraping.factor
extra/sequences/extras/extras.factor
misc/vim/syntax/factor.vim

index c6d260b6d91c5fb720d6e137fe7b85d321421b15..867c5b1afb44ac0840a1b65c2427bbf00773f412 100644 (file)
@@ -121,7 +121,7 @@ PRIVATE>
 
 : framework-find ( name -- path )
     dup dyld-find [ nip ] [
-        ".framework" over start [
+        ".framework" over subseq-start [
             dupd head
         ] [
             [ ".framework" append ] keep
index 9eb30d7467021248b36b659afb35f049240a628c..44518c6ad97bce779f17a242f51e811d22eb0b82 100644 (file)
@@ -338,7 +338,7 @@ M: iokit-game-input-backend get-controllers ( -- sequence )
     +controller-states+ get-global keys [ controller boa ] map ;
 
 : ?join ( pre post sep -- string )
-    2over start [ swap 2nip ] [ [ 2array ] dip join ] if ;
+    2over subseq-start [ swap 2nip ] [ [ 2array ] dip join ] if ;
 
 M: iokit-game-input-backend product-string ( controller -- string )
     handle>>
index 1d72c04c43ea55965704c7d2e8947d90b1741a5f..2ec80f298393a16c258f52fcae8a647f144bdfe9 100644 (file)
@@ -25,7 +25,7 @@ M: template-lexer skip-word
 DEFER: <% delimiter
 
 : check-<% ( lexer -- col )
-    "<%" swap [ line-text>> ] [ column>> ] bi start* ;
+    "<%" swap [ line-text>> ] [ column>> ] bi subseq-start-from ;
 
 : found-<% ( accum lexer col -- accum )
     [
index a089fa3972ff63491b21d00af2ece8e39e90b104..38c613b9c43a036c48f47aac22eb2c3cc4a97746 100644 (file)
@@ -4,16 +4,13 @@ USING: accessors arrays assocs binary-search grouping kernel
 locals make math math.order sequences sequences.private sorting ;
 IN: interval-maps
 
+! Intervals are triples of { start end value }
 TUPLE: interval-map { array array read-only } ;
 
 <PRIVATE
 
-ALIAS: start first-unsafe
-ALIAS: end second-unsafe
-ALIAS: value third-unsafe
-
 : find-interval ( key interval-map -- interval-node )
-    array>> [ start <=> ] with search nip ; inline
+    array>> [ first-unsafe <=> ] with search nip ; inline
 
 : interval-contains? ( key interval-node -- ? )
     first2-unsafe between? ; inline
@@ -22,7 +19,7 @@ ALIAS: value third-unsafe
     [ [ dup number? [ dup 2array ] when ] dip ] { } assoc-map-as ;
 
 : disjoint? ( node1 node2 -- ? )
-    [ end ] [ start ] bi* < ;
+    [ second-unsafe ] [ first-unsafe ] bi* < ;
 
 : ensure-disjoint ( intervals -- intervals )
     dup [ disjoint? ] monotonic?
@@ -42,14 +39,14 @@ PRIVATE>
     check-interval-map
     [ drop ] [ find-interval ] 2bi
     [ nip ] [ interval-contains? ] 2bi
-    [ value t ] [ drop f f ] if ; inline
+    [ third-unsafe t ] [ drop f f ] if ; inline
 
 : interval-at ( key map -- value ) interval-at* drop ; inline
 
 : interval-key? ( key map -- ? ) interval-at* nip ; inline
 
 : interval-values ( map -- values )
-    check-interval-map array>> [ value ] map ;
+    check-interval-map array>> [ third-unsafe ] map ;
 
 : <interval-map> ( specification -- map )
     all-intervals [ first-unsafe second-unsafe ] sort-with
index 6668a3c9102cc7ecbbc3261a9508964e5be33ade..32b671d212c577f75a151c2d5f33462549635a41 100644 (file)
@@ -7,6 +7,7 @@ SPECIALIZED-ARRAY: uint
 IN: interval-sets
 ! Sets of positive integers
 
+! Intervals are a pair of { start end }
 TUPLE: interval-set { array uint-array read-only } ;
 
 <PRIVATE
@@ -29,11 +30,8 @@ PRIVATE>
 : spec>pairs ( sequence -- intervals )
     [ dup number? [ dup 2array ] when ] map ;
 
-ALIAS: start first-unsafe
-ALIAS: end second-unsafe
-
 : disjoint? ( node1 node2 -- ? )
-    [ end ] [ start ] bi* < ;
+    [ second-unsafe ] [ first-unsafe ] bi* < ;
 
 : (delete-redundancies) ( seq -- )
     dup length {
index d8daba5be1d3ba031ae6fffada6e9febe969396a..2072b7cbd4cfb9c17998ad90c8ecec334b0561c0 100644 (file)
@@ -46,7 +46,7 @@ C: <mime-variable> mime-variable
 : dump-until-separator ( multipart -- multipart )
     dup
     [ current-separator>> ] [ bytes>> ] bi
-    [ nip ] [ start ] 2bi [
+    [ nip ] [ subseq-start ] 2bi [
         cut-slice
         [ mime-write ]
         [ over current-separator>> length short tail-slice >>bytes ] bi*
index 69389f68c26f2ccdab161cd22614a9c59c3540b8..ce5abbeac5ce1b17ef9836c45fbf6407bcf07414 100644 (file)
@@ -42,7 +42,7 @@ SYNTAX: STRING:
 :: (scan-multiline-string) ( i end lexer -- j )
     lexer line-text>> :> text
     lexer still-parsing? [
-        end text i start* [| j |
+        end text i subseq-start-from [| j |
             i j text subseq % j end length +
         ] [
             text i short tail % CHAR: \n ,
index 93fea04e4d7318ad77440c98b471298cbeb36c8f..d57a4747697bc811af725d246426bd544c99fb99 100644 (file)
@@ -141,7 +141,7 @@ PRIVATE>
         { [ dup "/" head? ] [ nip ] }
         { [ dup empty? ] [ drop ] }
         { [ over "/" tail? ] [ append ] }
-        { [ "/" pick start not ] [ nip ] }
+        { [ "/" pick subseq-start not ] [ nip ] }
         [ [ "/" split1-last drop "/" ] dip 3append ]
     } cond ;
 
index adc7a750cad2b3fb76a32668a369e733dd2b111b..8d70f695bf852e2999c0c25b4b0547ea1e3399b8 100644 (file)
@@ -1146,11 +1146,11 @@ HELP: cut*
 { $values { "seq" sequence } { "n" "a non-negative integer" } { "before" sequence } { "after" sequence } }
 { $description "Outputs a pair of sequences, where " { $snippet "after" } " consists of the last " { $snippet "n" } " elements of " { $snippet "seq" } ", while " { $snippet "before" } " holds the remaining elements. Both output sequences have the same type as " { $snippet "seq" } "." } ;
 
-HELP: start*
+HELP: subseq-start-from
 { $values { "subseq" sequence } { "seq" sequence } { "n" "a start index" } { "i" "a start index" } }
 { $description "Outputs the start index of the first contiguous subsequence equal to " { $snippet "subseq" } ", starting the search from the " { $snippet "n" } "th element. If no matching subsequence is found, outputs " { $link f } "." } ;
 
-HELP: start
+HELP: subseq-start
 { $values { "subseq" sequence } { "seq" sequence } { "i" "a start index" } }
 { $description "Outputs the start index of the first contiguous subsequence equal to " { $snippet "subseq" } ", or " { $link f } " if no matching subsequence is found." } ;
 
@@ -1859,7 +1859,7 @@ ARTICLE: "sequences-search" "Searching sequences"
     last-index-from
 }
 "Finding the start of a subsequence:"
-{ $subsections start start* }
+{ $subsections subseq-start subseq-start-from }
 "Finding the index of an element satisfying a predicate:"
 { $subsections
     find
index 055392e882081b8b776e073d7f5e9ff787bd31a7..7ff518819e6293acbd1b00e16bbd645a45536492 100644 (file)
@@ -972,20 +972,20 @@ PRIVATE>
 
 <PRIVATE
 
-: (start) ( subseq seq n length -- subseq seq ? )
+: (subseq-start-from) ( subseq seq n length -- subseq seq ? )
     [
         [ 3dup ] dip [ + swap nth-unsafe ] keep rot nth-unsafe =
     ] all-integers? nip ; inline
 
 PRIVATE>
 
-: start* ( subseq seq n -- i )
+: subseq-start-from ( subseq seq n -- i )
     pick length [ pick length swap - 1 + ] keep
-    [ (start) ] curry (find-integer) 2nip ;
+    [ (subseq-start-from) ] curry (find-integer) 2nip ;
 
-: start ( subseq seq -- i ) 0 start* ; inline
+: subseq-start ( subseq seq -- i ) 0 subseq-start-from ; inline
 
-: subseq? ( subseq seq -- ? ) start >boolean ;
+: subseq? ( subseq seq -- ? ) subseq-start >boolean ;
 
 : drop-prefix ( seq1 seq2 -- slice1 slice2 )
     2dup mismatch [ 2dup min-length ] unless*
index 5a413b916ec6572adfe5f1cfeea37c4927f03a19..841b0125b4d9fc18f24eaf505ffaeb744da48a9a 100644 (file)
@@ -30,7 +30,7 @@ PRIVATE>
 : (split1) ( seq subseq snip-quot -- before after )
     [
         swap [
-            [ drop length ] [ start dup ] 2bi
+            [ drop length ] [ subseq-start dup ] 2bi
             [ [ nip ] [ + ] 2bi t ]
             [ 2drop f f f ]
             if
index ae3b8746204f81b762fe03511957478c5da52298..28feb10d15b976af2544c67cd694c3871d094285 100644 (file)
@@ -12,14 +12,14 @@ vectors ;
 { "abc" } [ "ab" "c" append ] unit-test
 { "abc" } [ "a" "b" "c" 3append ] unit-test
 
-{ 3 } [ "a" "hola" start ] unit-test
-{ f } [ "x" "hola" start ] unit-test
-{ 0 } [ "" "a" start ] unit-test
-{ 0 } [ "" "" start ] unit-test
-{ 0 } [ "hola" "hola" start ] unit-test
-{ 1 } [ "ol" "hola" start ] unit-test
-{ f } [ "amigo" "hola" start ] unit-test
-{ f } [ "holaa" "hola" start ] unit-test
+{ 3 } [ "a" "hola" subseq-start ] unit-test
+{ f } [ "x" "hola" subseq-start ] unit-test
+{ 0 } [ "" "a" subseq-start ] unit-test
+{ 0 } [ "" "" subseq-start ] unit-test
+{ 0 } [ "hola" "hola" subseq-start ] unit-test
+{ 1 } [ "ol" "hola" subseq-start ] unit-test
+{ f } [ "amigo" "hola" subseq-start ] unit-test
+{ f } [ "holaa" "hola" subseq-start ] unit-test
 
 { "Beginning" } [ "Beginning and end" 9 head ] unit-test
 
index 39a3504698046f35a9c9ad4726b703424fb815df..dc9e7fa7c59a37bdc53897d650ee335622a7ddea 100644 (file)
@@ -41,23 +41,23 @@ IN: combinators.extras.tests
 
 { "hi " "there" } [
     "hi there" {
-        { [ "there" over start ] [ cut ] }
+        { [ "there" over subseq-start ] [ cut ] }
         [ f ]
     } cond*
 ] unit-test
 
 { "hi " "there" } [
     "hi there" {
-        { [ "foo" over start ] [ head f ] }
-        { [ "there" over start ] [ cut ] }
+        { [ "foo" over subseq-start ] [ head f ] }
+        { [ "there" over subseq-start ] [ cut ] }
         [ f ]
     } cond*
 ] unit-test
 
 { "hi there" f } [
     "hi there" {
-        { [ "foo" over start ] [ head f ] }
-        { [ "bar" over start ] [ cut ] }
+        { [ "foo" over subseq-start ] [ head f ] }
+        { [ "bar" over subseq-start ] [ cut ] }
         [ f ]
     } cond*
 ] unit-test
index ab6158b6395147e8799be1dc73bc27481846bd01..12da3efd9780057d73c028ef562e3b315d16eccd 100644 (file)
@@ -17,7 +17,7 @@ default-8bit-encoding [ latin1 ] initialize
 
 : prolog-encoding ( string -- iana-encoding )
     '[
-        _ "encoding=" over start
+        _ "encoding=" over subseq-start
         10 + swap [ [ 1 - ] dip nth ] [ index-from ] [ swapd subseq ] 2tri
     ] [ drop "UTF-8" ] recover ;
 
index e7b585bf0d5b030edf1216c6c9fd49fc66178e5c..91a1d3294c4008984f43af1f702794bb85b8d554 100644 (file)
@@ -80,7 +80,7 @@ SYMBOL: sieve
     ] each sieve get ;
 
 : consecutive-under ( m limit -- n/f )
-    prime-tau-upto [ dup <repetition> ] dip start ;
+    prime-tau-upto [ dup <repetition> ] dip subseq-start ;
 
 PRIVATE>
 
index 402a960124e28422ceadd9f03249ac68bb4ac10d..c44ef62554227e086c8f199df237cda4138ca5a9 100644 (file)
@@ -16,6 +16,6 @@ IN: rosetta-code.web-scraping
 
 : web-scraping-main ( -- )
     "http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get nip
-    [ "UTC" swap start [ 9 - ] [ 1 - ] bi ] keep subseq print ;
+    [ "UTC" swap subseq-start [ 9 - ] [ 1 - ] bi ] keep subseq print ;
 
 MAIN: web-scraping-main
index 5ae2255a802785590e939c05970da8f21c06a7ea..4cb2536f7c388a099fa318a2c92c74c59fe2e84a 100644 (file)
@@ -579,7 +579,7 @@ PRIVATE>
 
 :: (start-all) ( subseq seq increment -- indices )
     0
-    [ [ subseq seq ] dip start* dup ]
+    [ [ subseq seq ] dip subseq-start-from dup ]
     [ [ increment + ] keep ] produce nip ;
 
 : start-all ( subseq seq -- indices )
index 1a8328fa4830388324bb36b7ed8135bfd9524032..6eb98a445bc9cf2ccbbe592baac55f25f87a337c 100644 (file)
@@ -57,7 +57,7 @@ syn keyword factorKeyword (clone) -rot 2bi 2bi* 2bi@ 2curry 2dip 2drop 2dup 2kee
 syn keyword factorKeyword 2cache <enum> >alist ?at ?of assoc assoc-all? assoc-any? assoc-clone-like assoc-combine assoc-diff assoc-diff! assoc-differ assoc-each assoc-empty? assoc-filter assoc-filter! assoc-filter-as assoc-find assoc-hashcode assoc-intersect assoc-like assoc-map assoc-map-as assoc-partition assoc-refine assoc-reject assoc-reject! assoc-reject-as assoc-size assoc-stack assoc-subset? assoc-union assoc-union! assoc= assoc>map assoc? at at* at+ cache change-at clear-assoc delete-at delete-at* enum enum? extract-keys harvest-keys harvest-values inc-at key? keys map>alist map>assoc maybe-set-at new-assoc of push-at rename-at set-at sift-keys sift-values substitute unzip value-at value-at* value? values zip zip-as zip-index zip-index-as
 syn keyword factorKeyword 2cleave 2cleave>quot 3cleave 3cleave>quot 4cleave 4cleave>quot alist>quot call-effect case case-find case>quot cleave cleave>quot cond cond>quot deep-spread>quot execute-effect linear-case-quot no-case no-case? no-cond no-cond? recursive-hashcode shallow-spread>quot spread to-fixed-point wrong-values wrong-values?
 syn keyword factorKeyword (all-integers?) (each-integer) (find-integer) * + - / /f /i /mod 2/ 2^ < <= <fp-nan> > >= >bignum >fixnum >float >fraction >integer >rect ?1+ abs align all-integers? bignum bignum? bit? bitand bitnot bitor bits>double bits>float bitxor complex complex? denominator double>bits each-integer even? fast-gcd find-integer find-last-integer fixnum fixnum? float float>bits float? fp-bitwise= fp-infinity? fp-nan-payload fp-nan? fp-qnan? fp-sign fp-snan? fp-special? gcd if-zero imaginary-part integer integer>fixnum integer>fixnum-strict integer? log2 log2-expects-positive log2-expects-positive? mod neg neg? next-float next-power-of-2 number number= number? numerator odd? power-of-2? prev-float ratio ratio? rational rational? real real-part real? recip rect> rem sgn shift sq times u< u<= u> u>= unless-zero unordered? when-zero zero?
-syn keyword factorKeyword 1sequence 2all? 2each 2each-from 2map 2map-as 2map-reduce 2reduce 2selector 2sequence 3append 3append-as 3each 3map 3map-as 3sequence 4sequence <repetition> <reversed> <slice> ?first ?last ?nth ?second ?set-nth accumulate accumulate! accumulate-as all? any? append append! append-as assert-sequence assert-sequence= assert-sequence? binary-reduce bounds-check bounds-check? bounds-error bounds-error? but-last but-last-slice cartesian-each cartesian-map cartesian-product change-nth check-slice clone-like collapse-slice collector collector-for concat concat-as copy count cut cut* cut-slice delete-all delete-slice drop-prefix each each-from each-index empty? exchange filter filter! filter-as find find-from find-index find-index-from find-last find-last-from first first2 first3 first4 flip follow fourth glue halves harvest head head* head-slice head-slice* head? if-empty immutable immutable-sequence immutable-sequence? immutable? index index-from indices infimum infimum-by insert-nth interleave iota iota-tuple iota-tuple? join join-as last last-index last-index-from length lengthen like longer longer? longest map map! map-as map-find map-find-last map-index map-index-as map-integers map-reduce map-sum max-length member-eq? member? midpoint@ min-length mismatch move new-like new-resizable new-sequence non-negative-integer-expected non-negative-integer-expected? nth nths pad-head pad-tail padding partition pop pop* prefix prepend prepend-as produce produce-as product push push-all push-either push-if reduce reduce-index reject reject! reject-as remove remove! remove-eq remove-eq! remove-nth remove-nth! repetition repetition? replace-slice replicate replicate-as rest rest-slice reverse reverse! reversed reversed? second selector selector-for sequence sequence-hashcode sequence= sequence? set-first set-fourth set-last set-length set-nth set-second set-third short shorten shorter shorter? shortest sift slice slice-error slice-error? slice? snip snip-slice start start* subseq subseq? suffix suffix! sum sum-lengths supremum supremum-by surround tail tail* tail-slice tail-slice* tail? third trim trim-head trim-head-slice trim-slice trim-tail trim-tail-slice unclip unclip-last unclip-last-slice unclip-slice unless-empty virtual-exemplar virtual-sequence virtual-sequence? virtual@ when-empty
+syn keyword factorKeyword 1sequence 2all? 2each 2each-from 2map 2map-as 2map-reduce 2reduce 2selector 2sequence 3append 3append-as 3each 3map 3map-as 3sequence 4sequence <repetition> <reversed> <slice> ?first ?last ?nth ?second ?set-nth accumulate accumulate! accumulate-as all? any? append append! append-as assert-sequence assert-sequence= assert-sequence? binary-reduce bounds-check bounds-check? bounds-error bounds-error? but-last but-last-slice cartesian-each cartesian-map cartesian-product change-nth check-slice clone-like collapse-slice collector collector-for concat concat-as copy count cut cut* cut-slice delete-all delete-slice drop-prefix each each-from each-index empty? exchange filter filter! filter-as find find-from find-index find-index-from find-last find-last-from first first2 first3 first4 flip follow fourth glue halves harvest head head* head-slice head-slice* head? if-empty immutable immutable-sequence immutable-sequence? immutable? index index-from indices infimum infimum-by insert-nth interleave iota iota-tuple iota-tuple? join join-as last last-index last-index-from length lengthen like longer longer? longest map map! map-as map-find map-find-last map-index map-index-as map-integers map-reduce map-sum max-length member-eq? member? midpoint@ min-length mismatch move new-like new-resizable new-sequence non-negative-integer-expected non-negative-integer-expected? nth nths pad-head pad-tail padding partition pop pop* prefix prepend prepend-as produce produce-as product push push-all push-either push-if reduce reduce-index reject reject! reject-as remove remove! remove-eq remove-eq! remove-nth remove-nth! repetition repetition? replace-slice replicate replicate-as rest rest-slice reverse reverse! reversed reversed? second selector selector-for sequence sequence-hashcode sequence= sequence? set-first set-fourth set-last set-length set-nth set-second set-third short shorten shorter shorter? shortest sift slice slice-error slice-error? slice? snip snip-slice subseq-start subseq-start-from subseq subseq? suffix suffix! sum sum-lengths supremum supremum-by surround tail tail* tail-slice tail-slice* tail? third trim trim-head trim-head-slice trim-slice trim-tail trim-tail-slice unclip unclip-last unclip-last-slice unclip-slice unless-empty virtual-exemplar virtual-sequence virtual-sequence? virtual@ when-empty
 syn keyword factorKeyword +@ change change-global counter dec get get-global get-namestack global inc init-namespaces initialize namespace off on set set-global set-namestack toggle with-global with-scope with-variable with-variables
 syn keyword factorKeyword 1array 2array 3array 4array <array> >array array array? pair pair? resize-array
 syn keyword factorKeyword (each-stream-block) (each-stream-block-slice) (stream-contents-by-block) (stream-contents-by-element) (stream-contents-by-length) (stream-contents-by-length-or-block) +byte+ +character+ bad-seek-type bad-seek-type? bl contents each-block each-block-size each-block-slice each-line each-morsel each-stream-block each-stream-block-slice each-stream-line error-stream flush input-stream input-stream? invalid-read-buffer invalid-read-buffer? lines nl output-stream output-stream? print read read-into read-partial read-partial-into read-until read1 readln seek-absolute seek-absolute? seek-end seek-end? seek-input seek-output seek-relative seek-relative? stream-bl stream-contents stream-contents* stream-copy stream-copy* stream-element-type stream-flush stream-length stream-lines stream-nl stream-print stream-read stream-read-into stream-read-partial stream-read-partial-into stream-read-partial-unsafe stream-read-unsafe stream-read-until stream-read1 stream-readln stream-seek stream-seekable? stream-tell stream-write stream-write1 tell-input tell-output with-error-stream with-error-stream* with-error>output with-input-output+error-streams with-input-output+error-streams* with-input-stream with-input-stream* with-output+error-stream with-output+error-stream* with-output-stream with-output-stream* with-output>error with-streams with-streams* write write1