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

[REBOL] Re: New competition: do you accept the challenge?! :-)

From: sant4::wanadoo::fr at: 8-Nov-2007 18:44

;Using Rebcode ;At first i just tried to translate as-is: print "START..." s1: now/time/precise str: make string! 5000 finale: make string! 50000 blk: [i #"," j #"-"] do rebcode [][ repeat i 10000 [ head str clear str head str poke blk 1 i repeat j 500 [ poke blk 3 j apply tmp to [string! blk] insert str tmp -1 tail str ] head str next str insert finale str 4 tail finale ] head finale ] print "STOP!" print length? finale print (now/time/precise - s1) ; it's fast but no so much because the use of the command 'apply (to convert integers into strings) ; So i tried to convert integers myself using Table of strings and a (not so) tricky algorytm to concate big numbers. print "START..." s1: now/time/precise str: make string! 5000 finale: make string! 50000 digit: 0 digits: make block! 500 insert digits "0" repeat n 500 [insert tail digits form n] n: 0 do rebcode [][ repeat i 10000 [ head str clear str head str copy stri "," -1 set.i n i until [ ;concat digits to form a big number set.i digit n rem.i digit 10 div.i n 10 pickz char digits digit insert stri char -1 eq.i n 0 ] repeat j 500 [ insert str #"-" -1 pickz char digits j insert str char -1 insert str stri -1 tail str ] head str next str insert finale str 4 tail finale ] head finale ] print "STOP!" print length? finale print (now/time/precise - s1) ;so it's fast but is not 'Rebolish' anymore