clone

clone(x)

Try it yourself:


clone(): make an independent copy

clone(x) creates a copy of a value. It is most useful with arrays, matrices, and other mutable data where later changes must not alter the original object.

Why copying matters

In a calculation pipeline, reusing a matrix as working storage can unexpectedly change subsequent results. Clone the original before editing, then apply operations to the copy. For simple numbers, cloning has little visible effect because numbers are already value-like.

Matrix workflows

A common pattern is to clone a matrix, modify selected entries, and compare it to the source with compare(). Build or reshape data with matrixFromColumns(), extract a column(), or duplicate a structure with concat(). For a deep structural test, use deepEqual().

Practical expectation

clone() copies the value; it does not transform it or make an expression immutable forever. Use it before mutation, and verify the type you are copying when integrating with code that distinguishes arrays, matrices, and objects.

Try Clone in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions