Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > expressing variant when using iterators
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 1st June 04:20
julien blanc
External User
 
Posts: 1
Default expressing variant when using iterators



hello

here's my problem. I'm iterating on items of a DICTIONNARY. Here's the
scheme i use :

it : ITERATOR[E]
set : DICTIONNARY[E,K]

from
it := set.get_new_iteator_on_items
it.start
until
it.is_off
loop
do_something...
it.next
end

i would like to express (using a variant) that the number of elements
left to be computed is decreasing at each iteration. But i've no idea on
how to do it (i searched in both ITERATOR and DICTIONNARY class without
success). Is it possible ? I would like to write something like

variant
it.left

but such a function does not exist in class ITERATOR, nor it does in any
of its descendant (according to smarteiffel online docs, i'm using
smarteiffel 1.0).

thanks for your help

julien
  Reply With Quote


  sponsored links


2 1st June 04:20
guillaume_lemaÎtre
External User
 
Posts: 1
Default expressing variant when using iterators



i : INTEGER

from
it := set.get_new_iterator_on_items
it.start
variant
set.count - i
until
it.is_off
loop
-- ...
i := i + 1
it.next
end

I agree that having a specific instruction for the variant is not
satisfying, but... it works !
  Reply With Quote


  sponsored links


3 1st June 04:20
julien blanc
External User
 
Posts: 1
Default expressing variant when using iterators


hello

here's my problem. I'm iterating on items of a DICTIONNARY. Here's the
scheme i use :

it : ITERATOR[E]
set : DICTIONNARY[E,K]

from
it := set.get_new_iteator_on_items
it.start
until
it.is_off
loop
do_something...
it.next
end

i would like to express (using a variant) that the number of elements
left to be computed is decreasing at each iteration. But i've no idea on
how to do it (i searched in both ITERATOR and DICTIONNARY class without
success). Is it possible ? I would like to write something like

variant
it.left

but such a function does not exist in class ITERATOR, nor it does in any
of its descendant (according to smarteiffel online docs, i'm using
smarteiffel 1.0).

thanks for your help

julien
  Reply With Quote
4 1st June 04:20
guillaume_lemaÎtre
External User
 
Posts: 1
Default expressing variant when using iterators


i : INTEGER

from
it := set.get_new_iterator_on_items
it.start
variant
set.count - i
until
it.is_off
loop
-- ...
i := i + 1
it.next
end

I agree that having a specific instruction for the variant is not
satisfying, but... it works !
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666