World: r3wp
[Core] Discuss core issues
older newer | first last |
Tomc 21-Mar-2006 [3724x2] | should also be noted that other langs i.e. perl exibit the same behavior on windows do it is apt to be an OS call that decides two decimal places is wau too heady for its users |
that said it has been solved here and on the maillist several times | |
Geomol 21-Mar-2006 [3726x2] | Robert, here is my solution used in Canvas: form-decimal: func [n /local p d] [ n: form n if p: find n #"E" [ if d: remove find n #"." [d: index? d p: back p] if not d [if d: remove find n #"," [d: index? d p: back p]] if not d [d: index? p] either p/2 = #"-" [ insert/dup n #"0" (to-integer skip p 2) - d + 1 insert n "0." ][ insert/dup p #"0" (to-integer next p) - (index? p) + d ] clear find n #"E" ] n ] |
>> form-decimal 9E-2 == "0.09" | |
JaimeVargas 21-Mar-2006 [3728] | Robert you can use the PRINTF wrapper function in rebol.org. It helps with all kinds of number formating. |
Robert 21-Mar-2006 [3729] | Thanks a lot. But I really can't believe that this formatting stuff isn't supported by default. |
sqlab 22-Mar-2006 [3730x2] | >> form-decimal -0.099 == "0.-99" |
rebol [] form-decimal: func [n /local p d s] [ all [s: negative? n n: abs n] n: form n if p: find n #"E" [ d: index? any [ all [ d: remove find n #"." p: back p d] all [ d: remove find n #"," p: back p d] p ] either p/2 = #"-" [ insert/dup n #"0" (to-integer skip p 2) - d + 1 insert n "0." ][ insert/dup p #"0" (to-integer next p) - (index? p) + d ] clear find n #"E" ] if s [insert n "-"] n ] | |
Maxim 22-Mar-2006 [3732x2] | can anyone refresh my memory as to how to insert new lines within blocks so that saved blocks are tidy? |
I have searched the net, the update docs and have no found it. ' :-/ | |
Ladislav 22-Mar-2006 [3734] | see NEW-LINE |
Maxim 22-Mar-2006 [3735x3] | thanks ! I feel a little dumb ... hehe |
strange, I just searched it again, and for some reason, now, new-line is the first thing returned in google... damn... last week it wasn't in the first 3 pages > :-( | |
ahhh... I had searched for "rebol newline" , searching is subtle sometimes.<Petra2PnrXmlResponse> | |
Anton 23-Mar-2006 [3738] | I knew that name would cause trouble. |
Pekr 24-Mar-2006 [3739] | how to substract two dates including time? |
Sunanda 24-Mar-2006 [3740] | difference in recent versions will subtract dates and times |
Pekr 24-Mar-2006 [3741x2] | hmm, not sure .... is difference any different from date1 - date2 |
I mean - when substracting two 'now values, the time is not being taken into account .. | |
Sunanda 24-Mar-2006 [3743] | >> a: now - 125:00:00 == 19-Mar-2006/9:08:07 >> a - now == -5 ;; five days >> difference a now == -125:00:16 ;;; 125 hours That's the difference! >> |
Rebolek 24-Mar-2006 [3744] | There must be no timezone present |
Pekr 24-Mar-2006 [3745] | why should be difference call different to simple usage of minus op? |
Sunanda 24-Mar-2006 [3746] | it's a strange hack -- difference was originally for sets. So making it work for time is seriously non-orthogonal. |
Pekr 24-Mar-2006 [3747] | I hate those hacks |
JaimeVargas 24-Mar-2006 [3748] | Maybe we need three types instead of two. date! time! and idate! or stamp! |
Gabriele 24-Mar-2006 [3749] | difference hadles timezones too. |
Gregg 24-Mar-2006 [3750] | I don't like hacks, but the minus op is a very practical shortcut. Should it try to be smart and return days if no time exists for either arg; otherwise do the same thing DIFFERENCE does (and what time do you assume if only given for one arg; midnight UTC?)? |
Jarod 26-Mar-2006 [3751x4] | Can rebol do hashes of hashes, arrays of hashes, hashes of arrays, data structures within data structures, similar to the way Perl does it with references? |
I haven't actually seen documentation which explains concisely how to accomplish this with Rebol | |
it would be interesting if it could also do arrays of objects, and hashes of objects | |
but let's say I set some words to some blocks, and I put those words into another block, do I always have to reduce to actually see the stuff pointed to by the words in the blocks, or is there a way to actually insert the content of the words themselves into the blocks | |
Gregg 26-Mar-2006 [3755x2] | You can reduce or not; that is, the choice of when to evaluate is up to you; and, yes, any type of block can contain any type of data nested to any level. |
You need to be aware that the behavior of lists is *slightly* different than for blocks and hashes, WRT what INSERT does, etc. The Core manual covers it correctly I think. | |
Jarod 26-Mar-2006 [3757x7] | hmm |
but I mean, I don't want to have to reduce, I want to insert the actual values of the words into the list, not the word itself | |
when I insert the word, I have to reduce to show what the contents of the word actually are | |
let's say a: [value1 value2 value3] | |
and I want b to have a in it | |
b: [a] will have the word a, not value1 value2 value3 | |
what I do b: [a] and have it put value1 value2 value3 in b instead of a itself | |
ChristianE 26-Mar-2006 [3764] | you can do B: REDUCE[A], but if don't want to reduce you can also do sth. like B: [ ] APPEND B A But I think what your looking for is sth. like >> a: [1 2 3] b: [ ] >> append/only b a >> probe b >> [ [ 1 2 3 ] ] >> clear a == [ ] >> probe b == [ [ ] ] >> append a 4 probe b == [ [ 4 ] ] |
Jarod 26-Mar-2006 [3765] | why exactly is it called reduce also? |
Geomol 27-Mar-2006 [3766] | Because it reduce the words to their values? |
Anton 27-Mar-2006 [3767] | It reduces the expressions found within the block (and it returns the results in a new block). |
Jarod 27-Mar-2006 [3768x4] | I am also perplexed why rebol doesn't have a substring function, sure even if you can create one with a few extra commands, it seems to me like most people don't want to have to invent a language, just to use the functionality that exists. |
or I should rephrase that, to use functionality that exists in other languages | |
I hope rebol 3.0 has a substring function built in | |
even if source substring shows me the copy/part at stuff | |
Graham 27-Mar-2006 [3772] | A line in the sand has to be drawn somewhere. |
Jarod 27-Mar-2006 [3773] | substring is far more intuitive for someone who hasn't used rebol before than copy/part at |
older newer | first last |