Example FltVector copy 006




This example shows how a Vector may be modified destructively or non-destructively using the the copy and setq function.



The original Vector.

(define x #(float| 5.456699848175 3.141592025757 )) Returns: #<FltVector 123456>

The copied Vector using the copy function.

(setq z (copy x)) Returns: #<FltVector 234567>

The copied Vector using the setq function.

(setq twin x) Returns: #<FltVector 345678>

The container named z is a copy of x (both are Vectors) and z has a separate memory space. However, the containers named x and twin point to the same memory spaces on the heap. Therefore

(setq twin[1] 4.1234 ) Returns: #<FltVector 123456>

The setq command results in the contents of both twin and x being both the same.

twin[1] Returns: 4.1234
x[1] Returns: 4.1234

Since z points to a different memory space, it still retained the original value which was copied from x before the values of x were modified.

z[1] Returns: 3.141592025757

Notes and Hints

Using the setq function results in objects having the same object id. But the object that is being assigned the copied object has a different object id than original object. In this example twin and x have the same object id while z has a different object id.


Related Examples

Here are examples of the copy function at work.

BitVector copy 011 Brick copy 012 CpxVector copy 013 Dictionary copy 002
Directory copy 003 FltVector copy 006 IntVector copy 007 Lambda copy 008
List copy 010 Matrix copy 006 Matrix copy 007 NumMatrix copy 011
NumVector copy 008 ObjVector copy 009 Pair copy 009 PcodeVector copy 010
ShortVector copy 008 Structure copy 001 Vector copy 004 Vector copy 005


Function Links

Here is the link to the current function used in this example.


Here are a number of links to other related functions.



Argument Types

Here are the links to the data types of the arguments used in this example.


Here are a number of links to examples having similar argument types.

Dictionary isDictionary 001 FltVector addMethod 019 FltVector append 007 FltVector apply 005
FltVector binarySearch 005 FltVector cdr 006 FltVector compare 014 FltVector compareEQ 014
FltVector compareGE 014 FltVector compareGT 014 FltVector compareNE 014 FltVector comparison functions 014
FltVector copy 006 FltVector defmethod 017 FltVector delete 009 FltVector insert 005
FltVector isAtom 005 FltVector isEqual 013 FltVector isFloatVector 001 FltVector isIdentical 012
FltVector isObject 007 FltVector isType 016 FltVector length 008 FltVector map 005
FltVector mapc 005 FltVector methodsOf 017 FltVector new 009 FltVector ref 022
FltVector resize 006 FltVector reverse 003 FltVector send 015 FltVector setCdr 006
FltVector setLastCdr 006 FltVector setq 019 FltVector sizeof 014 FltVector sort 013
FltVector type 016 FltVector uniqueInsert 004 FltVector vectorFill 003 String isChar 001
String isCharAlphabetic 001 String isCharAlphanumeric 001 String isCharLowercase 001 String isCharName 001
String isCharNumeric 001 String isCharUppercase 001 String isCharWhitespace 001 String isEqual 001
String isEqual 002 String isObject 001 String isString 001 String isText 001
String isType 001 String isType 002 String isType 003 String sizeof 001
String string 001 String string 002 String string 003 String type 001
Symbol isCharName 002 Symbol isCharNumeric 002 Symbol isObject 002 Symbol isSymbol 001
Symbol isType 004 Symbol sizeof 002 Symbol type 002

Analytic Information Server (AIS)

AIS Component Systems

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