like ( seq exemplar -- newseq )
Factor handbook » The language » Collections » Sequence operations » Sequence protocol

Prev:lengthen ( n seq -- )
Next:new-sequence ( len seq -- newseq )


Vocabulary
sequences

Inputs
seqa sequence
exemplara sequence


Outputs
newseqa new sequence


Generic word contract
Outputs a sequence with the same elements as seq, but like the template sequence, in the sense that it either has the same class as the template sequence, or if the template sequence is a virtual sequence, the same class as the template sequence's underlying sequence.

The default implementation does nothing.

Notes
Unlike clone-like, the output sequence might share storage with the input sequence.

Examples
USING: prettyprint sequences ; { 1 2 3 } V{ } like .
V{ 1 2 3 }

Demonstrating the shared storage:
USING: kernel prettyprint sequences ; { 1 2 3 } dup V{ } like reverse! [ . ] bi@
{ 3 2 1 } V{ 3 2 1 }


Definition

GENERIC: like ( seq exemplar -- newseq ) flushable


Methods