bartlett ( n -- seq )


Vocabulary
math.extras

Inputs and outputs
nan integer
seqa sequence


Word description
Return the Bartlett window.

Definition
USING: arrays kernel math sequences ;

IN: math.extras

: bartlett ( n -- seq )
dup 1 <=
[ 1 = [ 1 1array ] [ { } ] if ] [
[ iota ] [ 1 - 2 / ] bi
[ [ recip * ] [ >= ] 2bi [ 2 swap - ] when ] curry map
] if ;