RE: Looking for the best "Parse"...

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

Euphoria allows certain reverse slices (see refman) which lets you 
simlify your code -

    k = n - m
    if v = 1 then
        p = r & u[m+1..n]
    elsif v = 1 + k then
        p = u[1..k] & r 
    else
        p = u[1..v-1] & r & u[v+m..n]
    end if

to this -

    p = u[1..v-1] & r & u[v+m..n]

Try it.  - Colin


Igor Kachan wrote:
> Hello Cassidy Napoli,
> 
> Just once more iteration with your program 
> and your very interesting *recursive* idea,
> which you can make with the 
> *delete doubl* method to get a simple 
> and understandable code.
> 
> Try please:
> 
> --[begin code]
> include wildcard.e
> 
> global function parseUserText
> (sequence u, --unParsedText -- u
>  sequence e, --escape       -- e
>  sequence r) --replace      -- r
> -- 
>  sequence p  --ParsedText   -- p
>   integer v  --varPos       -- v
>   integer m -- le
>   integer n -- lu
>   integer k
> --  
> 	  v = match(lower(e), lower(u)) -- add explanations in your
>    if not v then return u end if        -- native language and in English
> --
> 	  m = length(e) -- place for explanation
> 	  n = length(u) -- place for explanation
> 	  k = n - m -- place for explanation
>        if v = 1 -- place for explanation
>      then p = r & u[m+1..n] -- place for explanation
>     elsif v = 1 + k -- place for explanation
>      then p = u[1..k] & r -- place for explanation
>      else p = u[1..v-1] & r & u[v+m..n] -- place for explanation
>    end if -- place for explanation
>   return parseUserText(p,e,r) -- place for explanation
> end function
> 
> sequence text
> 
> text = parseUserText("The $A jumped over the lazy dog.","$A","quick 
> brown
> fox")
> 
> puts (1, text)
> 
> --[end code]
> 
> The speed is another question, it requires
> the bench-testings on monotasking OS,
> in plain Dos-32 mode, for example.
> 
> Regards,
> Igor Kachan
> kinz at peterlink.ru
> 
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu