Concatenate Function Example

Details

Action

This function concatenates either lists or strings.

1] As List concatenator:

Concatenate changes the list pointers to return its value. In general it is faster than Append. It can take any number of arguments, all of which must evaluate to lists (the last may be the empty list)).

Given two lists (A B) and (F G)

(1) (2)

 * *

/ \ / \

A * F *

 / \ / \

 B () G ()

Suppose that value[X] = (A B) and value[Y] = (F G) then

Concatenate(X,Y) creates the list (A B F G) by replacing the first pointer to ( ) with the dotted pointer to node (2).

(1) - - -> (2)

 

The call does the surgery, and what is returned is the new list:

(1)

 *

/ \

A *

  / \ = (A B F G)

B *

  / \

  F *

  / \

  G ()

Now when this is done, the value of X is (A B F G) since it returns the list pointed to by node (1). And this has been changed! Y has not been altered at all. The action is similar. When a longer list of lists is concatenated. This action has the effect of modifying all items in the system which contained pointers to node (1), the original X.

2] As String concatenator:

Concatenates two strings.

print concatenate("Hello ", "there!");

prints in TextField

Hello there!