Mailing List Archive: 49091 messages

## [REBOL] Re: [FIND] [FoxPro] Re: Find? Copy/Part?

### From: sqlab:gmx at: 19-Jan-2005 15:56

```
Hello

Can someone tell me why I get different results for n = 0
with these two variants?

find-nth0: func [
"Returns the series after the Nth occurrence of value or none."
series [series!]
value
N [integer!]
/local pos
] [
parse series [n [thru value]  pos: to end]
pos
]

find-nth1: func [
"Returns the series after the Nth occurrence of value or none."
series [series!]
value
N [integer!]
/local pos
] [
parse series [n thru value  pos: to end]
pos
]

>> find-nth1 "0**3*4" "*" 0
== none
>> find-nth0 "0**3*4" "*" 0
== "0**3*4"
>>

Or with other questions;
why is zero times [..] true
and zero times .. false?

Other n's give the same result

>> find-nth1 "0**3*4" "*" 3
== "4"
>> find-nth0 "0**3*4" "*" 3
== "4"

AR

>
> Andreas Bolka napsal(a):
>
> >Wednesday, January 19, 2005, 12:23:28 PM, Gabriele wrote:
> >
> >
> >
> >>so you'd need to check PARSE's result and return NONE if it didn't
> >>match.
> >>
> >>
> >
> >and so that this exercise is not left to the reader:
> >
> >    find-nth: func [
> >        "Returns the series at occurrence N of value or none."
> >        series [series!]
> >        value
> >        n [integer!]
> >        /local pos
> >    ] [
> >        either parse series [n [to value pos: value] to end] [pos] [none]
> >    ]
> >
> >
> >
> I sent my correction
>
>   find-nth: func [
>       "Returns the series at occurrence N of value or none."
>       series [series!]
>       value
>       n [integer!]
>       /local pos
>   ] [
>       if parse series [n [to value pos: value] to end] [pos]
>   ]
>
> immediately, but it didn't make it to the list yet :-(
>
> --
> To unsubscribe from the list, just send an email to rebol-request
> at rebol.com with unsubscribe as the subject.
>

--
GMX im TV ... Die Gedanken sind frei ... Schon gesehen?
Jetzt Spot online ansehen: http://www.gmx.net/de/go/tv-spot
```