clone-like ( seq exemplar -- newseq )


Vocabulary
sequences

Inputs
seqa sequence
exemplara sequence


Outputs
newseqa new sequence


Word description
Outputs a newly-allocated sequence with the same elements as seq but of the same type as exemplar.

Notes
Unlike like, this word always creates a new sequence which never shares storage with the original.

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

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


Definition

GENERIC: clone-like ( seq exemplar -- newseq ) flushable


Methods