sergiotaborda / lense-lang

The Lense Language Compiler
1 stars 0 forks source link

Support Progressions as first citizens #32

Open sergiotaborda opened 8 years ago

sergiotaborda commented 8 years ago

Support Progression class This is similar to Range types in other languages the difference is that step may not be 1 , not even linear. Progressions are not Intervals like Ranges.

Support literals 1 .. 10 to mean a progression from 1 to 10 inclusive.

This is useful to remove the need for a "primitive for directive" and use

for ( val k in 1 .. 10 ) {

}

A syntax for linear stepping should be devised. Also for non linear stepping. Possibilities

for ( val k in 1 .. 10.step(4) ) {
}
//that could be written 
for ( val k in 1 .. 10.next (   previous -> previous + 4) ) ) {
// this iterates over 1 , 4 , 9 only
}
// for non linear
for ( val k in 1 .. 10.next (   previous -> previous * 2 ) ) ) {
 // this iterates over 1 , 2 , 4 , 8 only
}