Handbook
Glossary
range
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Numeric ranges
Next:
[a..b] ( a b -- range )
Vocabulary
ranges
Definition
IN:
ranges
TUPLE:
range
{
from
read-only
}
{
length
read-only
}
{
step
read-only
}
;
Methods
USING:
classes.tuple
kernel
ranges
;
M:
range
hashcode*
tuple-hashcode
;
USING:
accessors
ranges
sequences
;
M:
range
length
length>>
;
inline
USING:
accessors
kernel
math
ranges
sequences.private
;
M:
range
nth-unsafe
[
step>>
*
]
keep
from>>
+
;
inline
USING:
kernel
math
ranges
sequences
;
M:
range
sum
[
length
]
[
first
]
[
last
]
tri
+
*
2
/
;
USING:
accessors
combinators.short-circuit
generic
kernel
math
math.statistics
ranges
sequences
;
M:
range
sum-of-cubes
dup
{
[
step>>
1
=
]
[
from>>
integer?
]
}
1&&
[
[
from>>
]
[
length>>
]
bi
dupd
+
[
<iota>
sum-of-cubes
]
bi@
swap
-
]
[
M\
range
sum-of-cubes
(call-next-method)
]
if
;
USING:
accessors
combinators.short-circuit
generic
kernel
math
math.statistics
ranges
sequences
;
M:
range
sum-of-quads
dup
{
[
step>>
1
=
]
[
from>>
integer?
]
}
1&&
[
[
from>>
]
[
length>>
]
bi
dupd
+
[
<iota>
sum-of-quads
]
bi@
swap
-
]
[
M\
range
sum-of-quads
(call-next-method)
]
if
;
USING:
accessors
combinators.short-circuit
generic
kernel
math
math.statistics
ranges
sequences
;
M:
range
sum-of-squares
dup
{
[
step>>
1
=
]
[
from>>
integer?
]
}
1&&
[
[
from>>
]
[
length>>
]
bi
dupd
+
[
<iota>
sum-of-squares
]
bi@
swap
-
]
[
M\
range
sum-of-squares
(call-next-method)
]
if
;