Not being used to the any/all construct (below) I find it a little hard to read. It does produce terse code, but then the original example could have been shortened up considerably too (if this is all there was to the problem). To solve the problem in the original context, the second 'find (in the original example) could simply have been replaced by the previous 'find result in 'result. Thus: char-pos: func [str[string!] ch[char!] /local result] [ result: find/case str ch either equal? result none [return 0] [return index? result] ] Reducing this example could look like: char-pos: func [str[string!] ch[char!] /local result] [ either result: find/case str ch [index? result] [0] ] - Michael Jelinek -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 17, 2000 2:19 PM To: [EMAIL PROTECTED] Subject: [REBOL] [REBOL]Finding characters in strings Re: Howdy Tim: I'm a big fan of ANY and ALL for instance like that char-pos: func [str [string!] ch [char!] /r][ any [all [r: find/case str ch index? r] 0] ] > Hi: > I have written a function to find the matching index > for a character in a string: > > ;code follows: > char-pos: func [str[string!] ch[char!] /local result] [ > result: find/case str ch either equal? result none > [return 0] [return index? find/case str ch] > ] ;I have had to use find/case twice because if ; I use > index? find str ch ; and i submit a character that is not > found in str ; I get the following error message from the > interpreter ** Script Error: index? expected series > argument of type: series port How can I change this > function so that I don't have to call find/case twice? > > Thanks In advance Tim > >
