World: r3wp
[Core] Discuss core issues
older newer | first last |
Geomol 1-Nov-2006 [5925x2] | And as a function: find-dups: func [blk] [unique head foreach e unique blk [alter copy blk e]] |
Maxim: Henrik didn't ask for speed! ;-) | |
Maxim 1-Nov-2006 [5927x2] | hehe... but I know he is addicted to it ;-) I had found my solution when I saw yours... so I just did a benchmark for the fun of it. |
you'll be intrigued to know that the unique call, is VERY slow. it was as long as my duplicates itself. | |
Geomol 1-Nov-2006 [5929] | Funny how the same thing can be done in so different ways with REBOL. I think, it's good. Choose the way, you like. Not many languages are like that. Again REBOL is much like a spoken language. You can say the same thing in lots of ways. Some say it with many words, some is short and precise, etc. |
Maxim 1-Nov-2006 [5930] | you have seen the old REBOL poetry discussion? IIRC they where on the mailing list... but not sure. |
Geomol 1-Nov-2006 [5931] | nope |
Maxim 1-Nov-2006 [5932] | some people where amazing. using only rebol core words and valid syntax... |
Geomol 1-Nov-2006 [5933] | :-) |
Maxim 1-Nov-2006 [5934] | writing subtle lines which often had nice printed results. |
Geomol 1-Nov-2006 [5935] | This one? http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlJVXQ |
Maxim 1-Nov-2006 [5936] | hehehe... I guess those where part of it... |
Gabriele 1-Nov-2006 [5937x4] | >> s: now/precise duplicates-max blk difference now/precise s == 0:00:02.062 >> s: now/precise duplicates blk difference now/precise s == 0:00:00.031 >> length? blk == 10000 |
duplicates: func [block /local result value] [ result: make block! 16 parse sort copy block [ any [set value skip some value (append result value) | skip] ] result ] | |
mine does not need unique either | |
on a small block the speed is almost the same (mine a little bit faster) | |
Maxim 1-Nov-2006 [5941] | yes parse was the other solution, I was going to explore. |
Gabriele 1-Nov-2006 [5942x2] | i wonder if counting each value would be faster, probably not. sort being native helps a lot :) |
if blk is already sorted then it's even faster (no copy required either) | |
Maxim 1-Nov-2006 [5944] | indeed, in this situation, parse is much more flexible. |
Maxim 2-Nov-2006 [5945] | Gabriele, your solution does not support words! duplicates [ a b c ] ** Script Error: Invalid argument: a ** Where: duplicates |
Gabriele 2-Nov-2006 [5946] | where's LITERAL when you need it? |
[unknown: 5] 2-Nov-2006 [5947] | Does anyone have any information on what strength or methods that ENCLOAK uses? For example, what bit strength etc, algorithm etc,? |
Maxim 2-Nov-2006 [5948] | encloak is not an encryptor, its an obfuscator. |
[unknown: 5] 2-Nov-2006 [5949] | you mean like an xor type thing? |
Maxim 2-Nov-2006 [5950] | I don't know exactly, but I remember reading that its not a real encryption system. |
[unknown: 5] 2-Nov-2006 [5951x2] | I had just found something via search it looked like Carl was question about it and answered something along the lines of XOR. Not sure if the function has evolved since then or not. |
ok Thanks Maxim. | |
Allen 2-Nov-2006 [5953] | Encloak -- http://www.rebol.net/cookbook/recipes/0023.html-- Carl says Newer versions of REBOL include "cloaking" functions for encrypting and decrypting strings. These functions do not provide full strength encryption such as Blowfish, AES, or RSA as found in REBOL/Command, nevertheless they can be useful for hiding passwords and other values. (That's why we call it cloaking rather than encrypting.) |
Maxim 2-Nov-2006 [5954] | so basically, usefull for hidding data from familly and friends, but not from your neighbourhood (or company) hacker ;-) |
Gabriele 3-Nov-2006 [5955] | well, the safety of XOR is the safety of the passphrase. if it is random and same length as data, then it's the safest possible. :) |
Sunanda 3-Nov-2006 [5956] | There are things stronger than encloak in the Library http://www.rebol.org/cgi-bin/cgiwrap/rebol/search.r?find=encryption |
Louis 3-Nov-2006 [5957x2] | Am I correct is assuming that data is more apt to actually be written to disk using write/direct than using write with the direct refinement? |
with = without | |
Anton 3-Nov-2006 [5959] | No, /direct just allows control of rebol's memory buffer. Rebol goes out to the host filesystem via host OS API calls. The host filesystem may still not actually write the data to disk immediately. To be sure of an immediate write, you would flush the disk cache, using a mechanism provided by the host OS and filesystem. (eg. in WinXP, if you disable one of the harddisks, it flushes the cache, then spins the disk down. There must be another way to flush the disk, but I never learned that.) |
Gabriele 3-Nov-2006 [5960] | in principle, there should be little difference. since write always creates a new file, and immediately closes the file port, they should basically be the same. I also assume that /append implies /direct in some way. |
sqlab 4-Nov-2006 [5961] | Since Rambo #3739 is still around, I never use write/append, but my own version with open/seek. |
Louis 4-Nov-2006 [5962] | Anton and Gabriele, thanks. |
Graham 4-Nov-2006 [5963] | >> age: 28-Dec-1923 == 28-Dec-1923 >> difference now age ** Math Error: Math or number overflow ** Near: difference now age |
PeterWood 4-Nov-2006 [5964x3] | It appears to be a problem with the +-50 year window around the current year which Rebol uses to assign the century to two-digit years: >> date-of-birth: 28-dec-1923 == 28-Dec-1923 >> age: func [dob [Date!] /local cutoff] [ [ cutoff: now [ cutoff/year: cutoff/year - 50 [ either dob < cutoff [ [ return (now - cutoff) + ((cutoff - 1) - dob)][ [ return now - dob] [ ] >> age date-of-birth == 30262 |
The calculation of the cutoff is not quite correct as on checking I found that Rebol sets the 50 year window at the start of the current year not from the current date. | |
>> date-of-birth: 28-dec-1923 == 28-Dec-1923 >> age: func [dob [date!] /local cutoff] [ [ cutoff: 1-1-06 [ cutoff/year: now/year - 50 [ either dob < cutoff [ [return (now - cutoff) + ((cutoff - 1) - dob)] [ [return now -dob] [ ] >> age date-of-birth == 30262 | |
Graham 4-Nov-2006 [5967] | should this be rambo'd ? |
Anton 5-Nov-2006 [5968] | If not in Rambo already, yes. |
Gabriele 5-Nov-2006 [5969x5] | graham, i think the problem there is that time! values cannot hold that much hours. |
>> now - 28-dec-1923 == 30263 | |
(days) | |
>> difference now 1-nov-1938 == 596192:12:37 | |
there's probably not much more room than some 600k hours. | |
Gregg 5-Nov-2006 [5974] | When I did a date-to-epoch func, I used ATTEMPT with DIFFERENCE and, if that failed, used subtraction to get the number of days, then multiplied by 86400.0. |
older newer | first last |