factor/basis/math/ranges/ranges-docs.factor

27 lines
1.5 KiB
Factor
Raw Normal View History

2008-08-13 15:19:58 -04:00
USING: help.syntax help.markup arrays sequences ;
2008-03-20 19:33:01 -04:00
IN: math.ranges
2009-04-06 04:00:46 -04:00
ARTICLE: "math.ranges" "Numeric ranges"
2008-08-13 15:19:58 -04:00
"A " { $emphasis "range" } " is a virtual sequence with real number elements "
2008-09-27 12:37:46 -04:00
"ranging from " { $emphasis "a" } " to " { $emphasis "b" } " by " { $emphasis "step" } ". Ascending as well as descending ranges are supported."
2008-08-13 15:19:58 -04:00
$nl
"The class of ranges:"
{ $subsection range }
"Creating ranges with integer end-points. The standard mathematical convention is used, where " { $snippet "(" } " or " { $snippet ")" } " denotes that the end-point itself " { $emphasis "is not" } " part of the range; " { $snippet "[" } " or " { $snippet "]" } " denotes that the end-point " { $emphasis "is" } " part of the range:"
{ $subsection [a,b] }
{ $subsection (a,b] }
{ $subsection [a,b) }
{ $subsection (a,b) }
{ $subsection [0,b] }
{ $subsection [1,b] }
{ $subsection [0,b) }
"Creating general ranges:"
{ $subsection <range> }
"Ranges are most frequently used with sequence combinators as a means of iterating over integers. For example,"
2008-09-27 12:37:46 -04:00
{ $code "3 10 [a,b] [ sqrt ] map" }
"Computing the factorial of 100 with a descending range:"
{ $code "100 1 [a,b] product" }
2008-08-13 15:19:58 -04:00
"A range can be converted into a concrete sequence using a word such as " { $link >array } ". In most cases this is unnecessary since ranges implement the sequence protocol already. It is necessary if a mutable sequence is needed, for use with words such as " { $link set-nth } " or " { $link change-each } "." ;
2009-04-06 04:00:46 -04:00
ABOUT: "math.ranges"