Re: Euphoria Standard Library

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

I find these two very useful:

--find any element of "fnd" in "in"
function find_any(sequence fnd,sequence in)
        for i = 1 to length(in) do
                if find(in[i],fnd) then
                        return i
                end if
        end for
        return 0
end function

--find "fnd" as the "sub_element" element of an element of "in"
--EXAMPLE:
--constant
IN={{"ONE","TWO"},{"THREE","FOUR"},{"FIVE","SIX"},{"SEVEN","EIGHT"},{"NINE","TEN"}}
--? sub_find("FOUR",IN,2) --returns 2
--? sub_find("FOUR",IN,1) --returns 0
function sub_find(object fnd, sequence in, integer sub_element)
    for i = 1 to length(in) do
        if length(in[i]) => sub_element and equal(fnd,in[i][sub_element]) then
            return i
        end if
    end for
    return 0
end function

Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

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

Search



Quick Links

User menu

Not signed in.

Misc Menu