Handbook
Glossary
powers ( n x -- seq )
Polynomials
Prev:
p^ ( p n -- p^n )
Next:
n*p ( n v -- w )
Vocabulary
math
.
polynomials
Inputs
n
an
integer
x
a
number
Outputs
seq
a
sequence
Word description
Output a sequence having
n
elements in the format:
{ 1 x x^2 x^3 ... }
.
Examples
USING: math.polynomials prettyprint ; 4 2 powers .
{ 1 2 4 8 }
Definition
USING:
kernel
math
sequences
;
IN:
math.polynomials
:
powers
( n x -- seq )
<repetition>
1
[
*
]
accumulate
nip
;