r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Louis
11-May-2006
[4341x2]
Which is fastest/best?      

y
 <> ch-db/2/drop

or 

ch-db/2/drop <> "y"
Or does it make any difference?
Tomc
11-May-2006
[4343x2]
with the constant first it does not have to decide/figure out the 
type of  'drop
should minutely  quicker
Allen
11-May-2006
[4345]
just be careful though, because you may end up compariing a 1 char 
string! vs a char! , you might not get the result you expect
y
 <> #"y"
== true
Louis
11-May-2006
[4346]
Thanks, Tomc and Allen. And Allen, I didn't realize that. Thanks 
for the warning!
Geomol
11-May-2006
[4347x2]
To test performance of some code, you can use this function:

time: func [:f /local t] [
	t: now/time/precise
	do f
	now/time/precise - t
]

Example:
>> time [loop 100000 [ch-db/2/drop <> "y"]]
== 0:00:00.34105
Btw. performance-wise the 2 ways look equal good.
Louis
11-May-2006
[4349]
Thanks, Geomol!
JaimeVargas
11-May-2006
[4350]
I recommend using time-blk.r from Ladislav it does multiple measurements 
until the measurement error is below supplied threshold.
Louis
11-May-2006
[4351]
Thanks Jaime, I'll check that out.
Henrik
12-May-2006
[4352]
is it possible to change file permissions via FTP with rebol?
[unknown: 9]
12-May-2006
[4353x3]
YEs.
We need to yell at Dan, and get him to post the source to FTPGadget. 
 It has examples of just about everything for FTP.
I truly don't even know what is holding that up.
Henrik
12-May-2006
[4356]
that would be nice
[unknown: 9]
12-May-2006
[4357]
I bitched at Cal and Dan.  I think there is nothing holding them 
up.  At one point it was that the code only ran on 1.2.5, so they 
should post this in the next few days.
Tomc
13-May-2006
[4358]
put it in their Qtask queue ...
[unknown: 9]
13-May-2006
[4359x2]
It is, but since it is not a priority it can't be given a deadline.
In fact, if you are part of the Qtask Contractors project, you can 
read everyone's tasks.
Henrik
14-May-2006
[4361]
is there an easy way to print numbers with thousands separators? 
I seem to keep resorting to complex solutions that not always work.
Graham
14-May-2006
[4362]
printf ?
PeterWood
14-May-2006
[4363]
This may help http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlVVYS

Found via the ML Topic Index under format/numbers with commas
Henrik
14-May-2006
[4364x4]
great! thanks
quite a bit of code there. hopefully my suggestion for EXTRACT for 
REBOL3 will be accepted :-) that would make this a whole lot simpler
oh, works only on integers :-(
graham, I looked at printf and it seems to require a DLL interface?
PeterWood
14-May-2006
[4368]
I don't think that printf will insert comma separators from looking 
at the man page.
Gabriele
14-May-2006
[4369x4]
I have this:
>> form-decimal 10 0
== "10"
>> form-decimal 10 2
== "10,00"
>> form-decimal 100000 2
== "100'000,00"
>> form-decimal 100000 0
== "100'000"
very old... result is rebol loadable
not sure code is readable... but if you want to play with it anyway...
Henrik
14-May-2006
[4373x2]
that looks good
as long as it's readable to rebol :-)
Graham
14-May-2006
[4375x2]
$ echo "1234567890" | perl -pe '1 while s/(.*)(\d)(\d\d\d)/$1$2,$3/'
   1,234,567,890
http://www.sunmanagers.org/pipermail/summaries/2002-December/002817.html
and there's an awk script on the same page
PeterWood
14-May-2006
[4377x2]
Try this thread, which includes a version of Gabriele's form-decimal 


http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlLTLK
All the versions are quite long though.
Henrik
14-May-2006
[4379]
gabriele's solution works fine here :-)
PeterWood
14-May-2006
[4380]
Did you notice the ; ***WARNING*** positive numbers only.
Gabriele
14-May-2006
[4381x7]
the version i sent him is the older, more generic one, which uses 
italian rules for formatting (, to separate decimals, ' to separate 
groups of 3 digits)
graham, the above regexp can be written in parse as:
digits: charset "1234567890" reverse rewrite reverse "1234567890" 
[[x: 4 digits] [(copy/part x 3) "," (pick x 4)
using my rewrite function
sorry, should be: digits: charset "1234567890" reverse rewrite reverse 
"1234567890" [[x: 4 digits] [(copy/part x 3) "," (pick x 4)]]
>> digits: charset "1234567890" reverse rewrite reverse "1234567890" 
[[x: 4 digits] [(copy/part x 3) "," (pick x 4)]]
== "1,234,567,890"
i wouldn't suggest doing it this way though ;)
Graham
14-May-2006
[4388x2]
to-comma: func [ n [number!]
	/local tx result
][
	tx: reverse form n
	result: copy ""
	while [ not tail? tx ][
		repend result [ part: copy/part tx 3]
		tx: skip tx 3
		if all [ not tail? tx 3 = length? part ][
			append result ","
		]
	]
	reverse result
]
no decimals ...
Gabriele
14-May-2006
[4390]
don't forget that if you use comma to group digits, you can't load 
it back in rebol anymore.