padding ( ... seq n elt quot: ( ... seq1 seq2 -- ... newseq ) -- ... newseq )


Vocabulary
sequences.private

Inputs
seqa sequence
na non-negative integer
eltan object
quota quotation with stack effect ( ... seq1 seq2 -- ... newseq )


Outputs
newseqa new sequence


Word description
Outputs a new string sequence of elt repeated, that when appended to seq, yields a sequence of length n. If the length of seq is greater than n, this word outputs an empty sequence.

Definition


: padding
( ... seq n elt quot: ( ... seq1 seq2 -- ... newseq ) -- ... newseq )
[
[ over length [-] dup 0 = [ drop ] ] dip
[ <repetition> ] curry
] dip compose if ; inline