Example Lambda copy 008

 

 

Description

This simple example shows how two copies of the same Lambda have similar but distinct persistent variables.

 

Details

The first Lambda is defined.

      (defun foo1(x) 
 	  pvars:(y) 
	  (defun sum(x) (+ x y))
	  (setq y x))    
        
Returns: #<Lambda 123456>

Invoke the Lambda foo1:

(foo1 9) Returns: 9
(foo1.sum 2) Returns: 11

Make a distinct copy of the Lambda foo1 and demonstrate how its persistent variables diverge from those of foo1.

(setq foo2 (copy foo1)) Returns: #<Lambda 234567>
(foo2.sum 2) Returns: 11
(foo2 20) Returns: 20
(foo2.sum 2) Returns: 22
(foo1.sum 2) Returns: 11

 

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.

copy

Here are a number of links to other related functions.

setq(#void)

 

Argument Types

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

Lambda

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

Context debug 001 Context debugBrowsableProcs 001 Context disassemble 001 Context globalBinding 001
Context inspect 001 Lambda argCount 001 Lambda argFetch 001 Lambda balance 001
Lambda callcc 001 Lambda compare 008 Lambda compareEQ 008 Lambda compareGE 008
Lambda compareGT 008 Lambda compareLT 008 Lambda compareNE 004 Lambda compile 001
Lambda copy 008 Lambda debug 001 Lambda debugBrowsableProcs 001 Lambda defchild 001
Lambda define 001 Lambda define(macro) 001 Lambda defmacro 001 Lambda defmacro 002
Lambda deforphan 001 Lambda defriend 001 Lambda defun 001 Lambda defun 002
Lambda disassemble 001 Lambda eval 001 Lambda exportTab 001 Lambda globalBinding 001
Lambda importTab 001 Lambda inspect 001 Lambda isLambda 001 Lambda lambda 001
Lambda makeLambda 001 Lambda myself 001 Lambda new 001 Lambda new 002
Lambda new 003 Lambda onError 001 Lambda send 008 Lambda send 009
Lambda setq 015 Lambda type 011 ObjectRepository detachLibrarian 001 ObjectRepository refLibrarian 001

Analytic Information Server (AIS)

AIS Component Systems

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