Handbook
Glossary
hailstone-main ( -- )
Vocabulary
rosetta-code
.
hailstone-sequence
Inputs
None
Outputs
None
Definition
USING:
arrays
io
kernel
math
prettyprint
ranges
sequences
;
IN:
rosetta-code.hailstone-sequence
:
hailstone-main
( -- )
27
hailstone
dup
dup
"The hailstone sequence from 27:"
print
" has length "
write
length
.
" starts with "
write
4
head
[
unparse
]
map
", "
join
print
" ends with "
write
4
tail*
[
unparse
]
map
", "
join
print
100000
[1..b)
[
[
hailstone
length
]
keep
2array
]
[
[
[
first
]
bi@
>
]
most
]
map-reduce
first2
"The hailstone sequence from "
write
pprint
" has length "
write
pprint
"."
print
;