Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [Find] Frustration with Find

From: carl::cybercraft::co::nz at: 1-Nov-2004 7:47

On Monday, 1-Novenber-2004 at 9:10:35 you wrote,
>I'm finding the behaviour of 'find to be a little counter intuitive. >When the value being searched for isn't found find returns none! rather >than the tail of the index. > >I wanted to code like : > >str: "abcde" >if not tail? str: find str "1" [......] > >However this throws up a script error as the value of str is set to >none! and it is now "disconnected" from the series! > > >> str: "abcde" >== "abcde" >if not tail? str: find str "1" [......] >** Script Error: tail? expected series argument of type: series port >bitset >** Near: if not tail? str: find > >> type? str >== none! > >I'd appreciate any comments and insight on why find returns a none! >value in these circumstances?
A none!'s returned because nothing was found perhaps? :-) My approach would be to use something like this...
>> str: "abcde"
== "abcde"
>> if found: find str "1" [str: found "etc..."] probe str
abcde == "abcde"
>> if found: find str "c" [str: found "etc..."] probe str
cde == "cde" Requires the creation of another word, but the code itself looks a little tidier (in my opinion, at least.) -- Carl Read.