1. Sequence initialisers for "for" loops
- Posted by Lmailles at AOL.COM Jun 30, 1998
- 558 views
for a=b to c by d do why can't for loops take sequences for a, b, c and d? for a={0,0,0} to {3,6,9} by {1,2,3} do standard sequence matching rules apply. b,c and d must have the same length -------------------------- Daniel Johnson Les Mailles Technologies "If you don't stand for God, you won't stand at all" -Isaiah
2. Re: Sequence initialisers for "for" loops
- Posted by Hawke <mdeland at NWINFO.NET> Jul 01, 1998
- 538 views
Lmailles at AOL.COM wrote: > for a=b to c by d do > why can't for loops take sequences for a, b, c and d? > for a={0,0,0} to {3,6,9} by {1,2,3} do > standard sequence matching rules apply. b,c and d > must have the same length IMHO: a worthy, logical, intuitive, clean, elegant and needed addition to Euphoria's interpreter. The core of the language is sequences and their manipulation. Using sequences in this manner, in loops, is natural. My unregistered (as soon as I sell a program, I'll register :) ) vote is a definitive and emphatic yes. take care--Hawke'
3. Re: Sequence initialisers for "for" loops
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Jul 01, 1998
- 548 views
- Last edited Jul 02, 1998
>Lmailles at AOL.COM wrote: >> for a=b to c by d do >> why can't for loops take sequences for a, b, c and d? >> for a={0,0,0} to {3,6,9} by {1,2,3} do >> standard sequence matching rules apply. b,c and d >> must have the same length > >IMHO: a worthy, logical, intuitive, clean, elegant and >needed addition to Euphoria's interpreter. The core >of the language is sequences and their manipulation. >Using sequences in this manner, in loops, is natural. >My unregistered (as soon as I sell a program, I'll >register :) ) vote is a definitive and emphatic yes. > >take care--Hawke' Yes, a brilliant and powerfull adition, wich is actually even more consistent that the present situation. I do find it ackwards at times to see when and when not things can work with objects as well. Consider this: type pos_object (object x) if x < 0 or not integer (x) then return FALSE else return TRUE end type end type It doesn't work as it is suppose to. Off course if it did, this would no longer work: function peek (object x) if integer (x) then .. ok.. no code could be here.. but its about the logic else .. same here end if end function I know it is too late to change, but sometimes I wonder if we would need a symbol or something to show that we want it to recursive, and as many times: <<a>> .. means recurse with sequence containing atoms (1D seq-thus) integer ( <a> ) .. recurse with atoms integer ( a ) would work as it normally does.. However.. <a> + <b> would be the new form of a + b So, you see, it is more clear, but too late unfortunately. No need to have different versions of Euphoria, but if there ever is gonna be a non-compatible version of Euphoria, keep this in mind Maybe we can partly have this with the normal boolean logic as some one else once brilliantly suggested: a * b -- Normal logic, we multiply all atoms a ** b -- New logic, we multply per 1D sequence a *** b -- New logic, per 2D sequence.. a // b -- A 1D-seq divide And off course the few builtin functions that don't recurse can have a new recursive function: integer_recurse ( a ) However, these could just be in an include file or something. Yes, its this impulse for consistency I keep having, but this actually adds a powerfull new trick, and won't break code, unlike the more preffered syntax with the << & >>'s. Ralf Nieuwenhuijsen nieuwen at xs4all.nl