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

[REBOL] Re: count function

From: jelinem1:nationwide at: 5-Jul-2001 9:33

I liked Anton's solution for 'count so well that I copied it and searched for agood place to put it into my shell.r - only to find that I already had a function to do this. Not as efficient (I've timed them for the case of searching strings) but takes a different approach: occur: function [ "Count the number of times the given value occurs in the given series" some-series [series!] some-value ][c][ c: 0 parse/all some-series [any [thru some-value (c: 1 + c)]] c ] - Michael Jelinek From: "Anton" <[arolls--bigpond--net--au]> on 07/05/2001 06:52 AM Please respond to [rebol-list--rebol--com] Sent by: [rebol-bounce--rebol--com] To: <[rebol-list--rebol--com]> cc: Subject: [REBOL] Re: count function Here's another way: count: func [s t /local n][ n: 0 while [s: find/tail s t][n: n + 1] ]