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

[REBOL] Re: count function

From: joel:neely:fedex at: 5-Jul-2001 10:09

Hi, Anton, Anton wrote:
> Here's another way: > > count: func [s t /local n][ > n: 0 > while [s: find/tail s t][n: n + 1] > ] >
I realize that the subject of zero is highly sensitive ;-) but the above only returns a count if T actually appears in S.
>> count: func [s t /local n][
[ n: 0 [ while [s: find/tail s t][n: n + 1] [ ]
>> count "ABCABCABC" "AB"
== 3 but
>> count "ABCABCABC" "D"
== none which is why I prefer to return N explicitly. -jn- ___________________________________________________________________ The purpose of computing is insight, not numbers! - R. W. Hamming joel'dot'neely'at'fedex'dot'com