Re: real world value flaw

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

> Sorry, Ralf.  You are incorrect.  And I wasn't doing this just to bother
> Robert or anyone else with a "fluke".
>
> I have some stats file that I'm trying to parse into values.  Its currently
> in the 100s.  Now, when the stats go over 1,000, I wonder if the service
> (which is not under my control) will use commas, which is the US way of
> separating thousands.  If it did, I wondered if Euphoria would be able to
> handle it.  The answer is, unfortunately, no.

Hmm, doesn't sound that hard to accomplish though.
Here's a short function that will help you out with, for example, this
'problem':

global function remove_item (object x, sequence s)
sequence result
integer pos
object item

    pos = find (x, s)
    if pos then
        result = s[1..pos-1]
        for index = pos+1 to length(s) do
            item = s[index]
            if not equal (item, x) then
                s = append(s, item)
            end if
        end for
        return result
    else
        return s
    end if
end function

And it should be pretty fast. (or at least its one of the fastest algorithms I
could come up with)
Though, consider this algorithm, faster for fewer cases.. (I suspect)

global function remove_item (object x, sequence s)

    for index = length(s) to 1 by -1 do
        if equal (s[index], x) then
            s = s[1..index-1] & s[index+1..length(s)]
        end if
    end for

    return s
end function

Anyway, here's your new value () statement:
value (remove_item(',', s))

However, this will not work when sequence definitions are used!
It simply couldn't because then, the interpreter has no way of knowing if a
'comma' means either a thousand separator or a next
element.
Comma's separating thousands are not used by computers, or for computer, but for
human-readability, therefor a package (which is
available) that adds and removes comma's from the input are what you need. Its
an interface issue, nothing more.

Ralf

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

Search



Quick Links

User menu

Not signed in.

Misc Menu