Re: Better Way to Do This

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

Is there a standard lib or more efficient function that could replace this? I'm using this for a type definition. The variable needs to be all sequences.

function no_atoms( sequence s ) 
integer i = 1 
	for t=1 to length(s) do 
		if atom(i) then return 0 end if 
	end for 
	return 1 
end function 

There is a Eu v4 library routine for this. It's in std/types.e

public type sequence_array( object x ) 
    if not sequence(x) then  
        return 0 
    end if 
	 
    for i = 1 to length(x) do 
        if not sequence(x[i]) then  
            return 0 
        end if 
    end for 
    return 1 
end type 

Note that this also allows empty sequences so if you must have at least one element you can use it like this ...

  if length(S) and sequence_array(S) then  
     ... 

By the way, your code above wouldn't work as you don't update the 'i' variable.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu