Looping/Sets

From dis-Emi-A

Jump to: navigation, search

I think I'd like to have this unified with Closures.

Looping/iteration on sets of data should be done in a universal format, and in a manner to would allow automatic parallel computation. As part of the avoiding if evilness it should also allow filtering.

Possible syntax:

[ i in set ]
{
    //something
}
[ i in set : i.cond() ]
{
    //something with i
}

The [] operator thus executes a code fragment iterating over the set in some fashion (ordering needs to be defined).  : is thus a general filter operator on a set, for the above it would need higher precedence than the "in" operator.

In order to fulfill a need for simple numeric loops there needs to be an easy way to create sequences.

 //full steps
 [ ndx in 0 .. 5 ] { ... }

 //half steps
 [ ndx in 0 .. 0.5 .. 4 ] { ... }
 //conciser than C
 //for( float ndx=0; ndx <=4; ndx += 0.5 )

Or do we use some kind of notation referring to number space and then use conditions.

[ ndx in Integers : 3 <= ndx < 8 ] { ... }

[ ndx in Reals : first(ndx) = 5 and next(ndx)=last(ndx) + 0.4 and ndx < 10] { ... }
//is not concise as C 
//for( float ndx=5; ndx < 10; ndx += 0.4 ) { ... }

It doesn't look like a good idea, mainly because of that second item trying to do real number iterations. </pre>

Personal tools