with

with --  traverses an array or list performing a statement.

Syntax

with symbol in|on s_exp do statement

with symbol1 in|on s_exp symbol2 = collect|tcollect statement

		

Arguments

symbol

Any Gamma or Lisp symbol.

s_exp

Any Gamma or Lisp expression.

statement

Any statement.

Returns

nil when using the do option, and the result of the statement when using the collect or tcollect option.

Description

with symbol in|on s_exp do statement

with symbol1 in|on s_exp symbol2 = collect|tcollect statement

Examples

    Gamma> A = array(1,2,3,4);
    [1 2 3 4]
    Gamma> with x in A do
    {
    x = x + 1;
    princ(x, "\n");
    }
    2
    3
    4
    5
    nil
    
    Gamma> 
    
    Gamma>  L = list (1, 2, 3, 4, 5, 6);
    (1 2 3 4 5 6)
    Gamma> with x on L do (princ(x,"\n"));
    (1 2 3 4 5 6)
    (2 3 4 5 6)
    (3 4 5 6)
    (4 5 6)
    (5 6)
    (6)
    nil
    nil
    Gamma> with x in L y = collect x + 2;
    (3 4 5 6 7 8)
    Gamma> y;
    (3 4 5 6 7 8)
    Gamma> with x in L y = tcollect x < 4 ? x : nil;
    (1 2 3)
    Gamma> y;
    (1 2 3)
    Gamma>  
    		

See the Stop Processes section of the Common Functions for Any Program chapter (Tutorial Two), or the Common: The Process Status Display section of the Controller Functions chapter in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

See Also

for, if, Statements

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.