Re: findany_from()

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

The use of magic numbers like this makes me uncomforatable.
In ten years we will be wondering what a program
doesn't work when sequences get to be more than a billion
atoms long.  Well, probably it will never be a problem
but why not use length(haystack)+1 instead of 1e9?

global function findany_from2(sequence needles, sequence haystack, integer
start)
    integer index,result
    if start > length(haystack) then
        return 0
    end if
    result=length(haystack)+1
    for i=1 to length(needles) do
    	index=find_from(needles[i],haystack,start)
    	if index and index<result then
    	    result=index
    	end if
    end for
    return remainder( result, length(haystack)+1 )
end function


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

Search



Quick Links

User menu

Not signed in.

Misc Menu