Re: foreach routine

new topic     » goto parent     » topic index » view thread      » older message » newer message

duke normandin wrote:

> Like I said in another post, I basically trying to emulate Perl's `foreach'
> routine, as in:
>      foreach $pair (@pairs){
>         do something
>      }
> 
> where @pairs is a simple array (no sweat! => a "U4ia" sequence)
>       $pair is a variable used in "list" context so it gets a string

include foreach.e
function do_something(integer x, object item, object extra)
   -- Do something with the item
   return 0
end function

sequence result
result = foreach(pairs, routine_id("do_something"))
if result[1] = 0 then
  -- No problems
else
  -- Something went wrong
end if

 

I know about 'foreach' as I use it all the time in the D programming language. D
is a bit like a static-typed, object-enabled, compiled Euphoria.

  http://www.digitalmars.com/d/statement.html#ForeachStatement

I also use it in the Progress 4GL (OpenEdge) which is a proprietary database
language.


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu