Faster lower() command

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

It's been a while since i've posted here. I recently put this together, from
code inside of the guru.ex file, and the current lower() command.

The one inside of guru.ex is used to handle sequence lowering, and atom
lowering is handled by the current function. I chose to use the current
command for atom lowering using the guru.ex method is quite slow with atoms.
function lower1( sequence x )
    integer c
    for i = 1 to length(x) do
        c = x[i]
        if c <= 'Z' then
            if c >= 'A' then
                x[i] = c + 32
            end if
        end if
    end for
return x
end function

function lower(object x)
    if sequence(x) then
        return lower1(x)
    else
        return x + (x >= 'A' and x <= 'Z') * TO_LOWER
    end if
end function


I put the sequence first, since I expect that lower() will mostly be used on
sequences. 

Any comments/questions/etc.?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu