X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=core%2Franges%2Franges.factor;h=4aff21ec1f1ea9d2f3f8e040bb3a264a6c6b94e2;hp=0373abcfe4d0dca1fa04d3202c703c6df9b05942;hb=46a70cb9022b0b2f381a218ab2a2ae30774df277;hpb=3135def3c9e2bc581f4224160d628ef6c79a7a3f diff --git a/core/ranges/ranges.factor b/core/ranges/ranges.factor index 0373abcfe4..4aff21ec1f 100644 --- a/core/ranges/ranges.factor +++ b/core/ranges/ranges.factor @@ -32,7 +32,10 @@ M: range hashcode* tuple-hashcode ; INSTANCE: range immutable-sequence -M: range sum [ length ] [ first ] [ last ] tri + * 2 / ; +M: range sum + dup length + [ drop 0 ] + [ swap [ first-unsafe ] [ last-unsafe ] bi + * 2 / ] if-zero ; : [0..b) ( b -- range ) 0 swap [a..b) ; inline : [1..b) ( b -- range ) 1 swap [a..b) ; inline - -! backwards compatibility for new syntax -ALIAS: [a,b] [a..b] deprecated -ALIAS: (a,b] (a..b] deprecated -ALIAS: [a,b) [a..b) deprecated -ALIAS: (a,b) (a..b) deprecated -ALIAS: [0,b] [0..b] deprecated -ALIAS: [1,b] [1..b] deprecated -ALIAS: [0,b) [0..b) deprecated -ALIAS: [1,b) [1..b) deprecated