copy

 

 

Overview

The copy function creates new copy of the object on the heap with its own unique object id. The new object id is returned by the copy function.

Structure

The copy function may appear similar to the setq function but its behavior is different if the target object is a collection object such as a Structure (Structures, vectors, lists and dictionaries are collection objects stored in the heap. See the Analytic Information Server Introduction Book). When you use the setq function to assign a native data type such as Number, Void, Boolean, Text, the immediate data is copied to the target container. When you use the setq function on a collection data type such as a Structure (source), a pointer to the data location (the object id) is copied to the target container (target). Therefore, if the new container (target) changes a value in the structure, the (source) container will show the change since (source) and (target) are pointing to the same data. (From a C-programmer's perspective, the source and target are pointer dereferencing the same memory location). However if the copy function was used, it produces a copy of the structure (target) in a different memory location. Changes to the copy are only visible to the (target) container. (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

Vector

The copy function returns an exact copy of a Vector object.

Brick

The copy function returns an exact copy of a Brick object.

Pair

The copy function returns an exact copy of a Pair.

List

The copy function returns an exact copy of a List.

Lambda

The copy function creates an exact copy of the specified Lambda object. The newly cloned Lambda has the same behavior and structure as the original Lambda with the exception that the cloned Lambda has a similar but distinct Pv structure. This allows cloning of Lambda objects, which have the same behavior but may have different values in their persistent variables.

Usage

The copy function may appear similar to the setq function but its behavior is different if the target object is a collection object such as a Vector (Structures, vectors, lists and dictionaries are collection objects stored in the heap). See the Analytic Information Server Introduction Book).

When you use the setq function to assign a native data type such as Number, Void, Boolean, Text, the immediate data is copied to the target container. When you use the setq function on a collection data type such as a Vector (source), a pointer to the data location (the object id) is copied to the target container (target). Therefore, if the new container (target) changes a value in the vector, the (source) container will show the change since (source) and (target) are pointing to the same data. (From a C-programmer's perspective, the source and target are pointer dereferencing the same memory location). However if the copy function was used, it produces a copy of the vector (target) in a different memory location. Changes to the copy are only visible to the (target) container. (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

Brick

The copy function may appear similar to the setq function but its behavior is different if the target object is a collection object such as a Brick (Structures, vectors, lists and dictionaries are collection objects stored in the heap. See the Analytic Information Server Introduction Book). When you use the setq function to assign a native data type such as Number, Void, Boolean, Text, the immediate data is copied to the target container. When you use the setq function on a collection data type such as a Brick (source), a pointer to the data location (the object id) is copied to the target container (target). Therefore, if the new container (target) changes a value in the brick, the (source) container will show the change since (source) and (target) are pointing to the same data. (From a C-programmer's perspective, the source and target are pointer dereferencing the same memory location). However if the copy function was used, it produces a copy of the brick (target) in a different memory location. Changes to the copy are only visible to the (target) container. (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

Structure

The copy function returns an exact copy of a structure object.

Dictionary

The copy function produces a copy of the Dictionary (target) in a different memory location (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

Directory

The copy function produces a copy of the Directory (target) in a different memory location (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

Matrix

The copy function may appear similar to the setq function but its behavior is different if the target object is a collection object such as a Matrix (Structures, vectors, lists and dictionaries are collection objects stored in the heap). See the Analytic Information Server Introduction Book).

When you use the setq function to assign a native data type such as Number, Void, Boolean, Text, the immediate data is copied to the target container. When you use the setq function on a collection data type such as a Matrix (source), a pointer to the data location (the object id) is copied to the target container (target). Therefore, if the new container (target) changes a value in the Matrix, the (source) container will show the change since (source) and (target) are pointing to the same data. (From a C-programmer's perspective, the source and target are pointer dereferencing the same memory location). However if the copy function was used, it produces a copy of the matrix (target) in a different memory location. Changes to the copy are only visible to the (target) container. (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

NumMatrix

The copy function may appear similar to the setq function but its behavior is different if the target object is a collection object such as a Matrix (Structures, vectors, lists and dictionaries are collection objects stored in the heap). See the Analytic Information Server Introduction Book).

When you use the setq function to assign a native data type such as Number, Void, Boolean, Text, the immediate data is copied to the target container. When you use the setq function on a collection data type such as a Matrix (source), a pointer to the data location (the object id) is copied to the target container (target). Therefore, if the new container (target) changes a value in the Matrix, the (source) container will show the change since (source) and (target) are pointing to the same data. (From a C-programmer's perspective, the source and target are pointer dereferencing the same memory location). However if the copy function was used, it produces a copy of the matrix (target) in a different memory location. Changes to the copy are only visible to the (target) container. (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

Pair

The copy function may appear similar to the setq function but its behavior is different if the target object is a collection object such as a Pair or List (Structures, vectors, lists and dictionaries are collection objects stored in the heap). See the Analytic Information Server Introduction Book).

When you use the setq function to assign a native data type such as Number, Void, Boolean, Text, the immediate data is copied to the target container. When you use the setq function on a collection data type such as a Pair (source), a pointer to the data location (the object id) is copied to the target container (target). Therefore, if the new container (target) changes a value in the Pair, the (source) container will show the change since (source) and (target) are pointing to the same data. (From a C-programmer's perspective, the source and target are pointer dereferencing the same memory location). However if the copy function was used, it produces a copy of the Pair (target) in a different memory location. Changes to the copy are only visible to the (target) container. (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

List

The copy function may appear similar to the setq function but its behavior is different if the target object is a collection object such as a Pair or List (Structures, vectors, lists and dictionaries are collection objects stored in the heap). See the Analytic Information Server Introduction Book).

When you use the setq function to assign a native data type such as Number, Void, Boolean, Text, the immediate data is copied to the target container. When you use the setq function on a collection data type such as a Pair (source), a pointer to the data location (the object id) is copied to the target container (target). Therefore, if the new container (target) changes a value in the Pair, the (source) container will show the change since (source) and (target) are pointing to the same data. (From a C-programmer's perspective, the source and target are pointer dereferencing the same memory location). However if the copy function was used, it produces a copy of the Pair (target) in a different memory location. Changes to the copy are only visible to the (target) container. (From a C-programmer's perspective, the copy function behaves like the memcpy standard function).

Lambda

Use this function when a multiple copies of the Lambda are required. For instance, if one has a blank expert Lambda, and one needs expert help on two separate subjects. Make two copies of the blank expert Lambda. Teach the first expert Lambda about subject one, and teach the second expert Lambda about subject two.

 

Syntax


Expression:

(copy vector)


Arguments Name Type Description
Argument:vectorVector ShortVector PcodeVector FltVector NumVector IntVector CpxVector ObjVector BitVector The Vector to be copied.

Returns:

An exact copy of the specified Vector.




Expression:

(copy struct)


Arguments Name Type Description
Argument:structStructure The structure to be copied.

Returns:

An exact copy of the specified Structure.




Expression:

(copy dictionary)


Arguments Name Type Description
Argument:dictionaryDictionary The Dictionary to be copied.

Returns:

An exact copy of the specified Dictionary.




Expression:

(copy directory)


Arguments Name Type Description
Argument:directoryDirectory The Directory to be copied.

Returns:

An exact copy of the specified Directory.




Expression:

(copy brick)


Arguments Name Type Description
Argument:brickBrick The Brick to be copied.

Returns:

An exact copy of the specified Brick.




Expression:

(copy matrix)


Arguments Name Type Description
Argument:matrixMatrix The Matrix to be copied.

Returns:

An exact copy of the specified Matrix.




Expression:

(copy nummatrix)


Arguments Name Type Description
Argument:nummatrixNumMatrix The NumMatrix to be copied.

Returns:

An exact copy of the specified NumMatrix.




Expression:

(copy pair)

(copy list)


Arguments Name Type Description
Argument:pairPair The Pair to be copied.
Argument:listList The List to be copied.

Returns:

An exact copy of the specified Pair.




Expression:

(copy list)


Arguments Name Type Description
Argument:listList The List to be copied.

Returns:

An exact copy of the specified List.




Expression:

(copy anLambda)


Arguments Name Type Description
Argument:anLambdaLambda The Lambda to be copied

Returns:

A new copy of the {anLambda} argument.



 

Examples

Here are a number of links to Lambda coding examples which contain this instruction in various use cases.

 

Argument Types

Here are the links to the data types of the function arguments.

Structure Dictionary Directory Pair
List Vector Brick Matrix
Lambda NumMatrix CpxVector ShortVector

Here are also a number of links to functions having arguments with any of these data types.

addMethod appendWriteln append apply
argCount argFetch associate attachLibrarian
balance binaryInsert binarySearch bitToNumberVector
boolean c::r callcc car
cdr class compareEQ compareGE
compareGT compareLE compareLT compareNE
compare comparison compile cons
copy count debugBrowsableProcs debugDetective
debug defchild defclass define(macro)
defineStructure define defmacro defmethod
deforphan defriend defstruct defun
deleteRows delete detachLibrarian dimension
disassemble display evalInSyncLocalContext eval
exportCsv exportSbf exportTab fieldsOf
findBlock find freeBlock globalBinding
importCsv importSbf importTab insertRows
insert inside inspect integer
isAtom isBitVector isBoolean isBound
isByteVector isCharAlphabetic isCharAlphanumeric isCharLowercase
isCharName isCharNumeric isCharUppercase isCharWhitespace
isChar isCharacter isClass isComplex
isDate isDictionary isDirectory isEqual
isError isFloatVector isIdentical isInside
isIntegerVector isInteger isLambda isMatrix
isMember isMoney isNumberMatrix isNumberVector
isNumber isObjectVector isObject isPair
isPcodeVector isString isStructure isSymbol
isText isType isVector lambda
last length lisp list
loadRepository macroReplace makeDictionary makeGaussianMatrix
makeGramMatrix makeLambda makeQuotedList makeStructure
map mapc matrixGaussianEliminate matrixGaussianSubstitute
member methodsOf money morph
myself new number objectToDictionary
objectToDirectory objectToList objectToMatrix objectToNumMatrix
objectToNumVector objectToStructure objectToVector offset
onError pair parent parse
pointer product proplist proprecord
putprop quote rank refAttributes
refLibrarian refValues ref remProp
remove resize reverse saveImmediate
saveObject saveRepository send setAttributes
setBlock setCar setCdr setLastCdr
setq sizeof sort sql
stringToBVector stringToVector string super
svmRegression type uniqueInsert vectorBinaryInnerProduct
vectorBipolarInnerProduct vectorCosineInnerProduct vectorCubeInnerProduct vectorDelete
vectorExpInnerProduct vectorFill vectorInnerProduct vectorLogInnerProduct
vectorQuartInnerProduct vectorQuintInnerProduct vectorSigmoidInnerProduct vectorSineInnerProduct
vectorSquareInnerProduct vectorTanInnerProduct vectorTanhInnerProduct writelg
writeln

Analytic Information Server (AIS)

AIS Component Systems

  • Smartbase Engine
  • QT C++ Libraries
  • MySQL Relational Database
  • AIS Lisp Libraries
  • Rapid Analytic Demo IDE