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

[REBOL] Re: Speed testing prime functions..

From: joel:neely:fedex at: 28-Nov-2001 18:47

Hi, again, Ladislav, Ladislav Mecir wrote:
> use [d] [ > d: [2 3 5 7] > prime?: function [p] [c s l] [ > l: to integer! square-root p > foreach v d [ > if p // v = 0 [return p = v] > if v >= l [return true] > ] > c: (last d) + s: 6 - ((last d) // 3 * 2) > while [c <= l] [ > if prime? c [ > append d c > if p // c = 0 [return false] > ] > c: c + s: 6 - s > ] > true > ] > ] >
Niceness restored!! After I made the point earlier about testing only thru the square root of the candidate, I'm glad you caught my omission of that in the latter functions! -jn- -- ; sub REBOL {}; sub head ($) {@_[0]} REBOL [] # despam: func [e] [replace replace/all e ":" "." "#" "@"] ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"} print head reverse despam "moc:xedef#yleen:leoj" ;