World: r3wp
[Core] Discuss core issues
older newer | first last |
Terry 12-May-2007 [7918] | (moving to DB Chat) |
Chris 12-May-2007 [7919x2] | Brian, try -- repeat x 10000 [unless attempt [to-word join "w" x][break/return x]] |
Warning: this will inhibit your ability to make new words in your console session. | |
Terry 13-May-2007 [7921] | any benchmark docs comparing certain functions with others? ie: foreach [ a b c ] n.. vs forskip n 3 ? |
Henrik 13-May-2007 [7922] | well, forskip is a mezzanine. you'd want fast loops to be done with natives like foreach |
Tomc 13-May-2007 [7923] | Joel Needly et .al. used to bench mark all sorts of things on the mail list a few years back .tthe benchmarks would likely need to be redone with current versions of rebol |
Ladislav 13-May-2007 [7924x3] | benchmarking: my site contains a very accurate block execution time measurement function |
(and I have got a benchmark there measuring overall speed using a couple of algorithms - they are derived from a Byte benchmark published in june 1988) - we are quite a bit faster than the C language was on an average computer back then :-p) | |
btw, accurate measurement shows, that the high resolution timer is not very accurate | |
Pekr 13-May-2007 [7927] | Ladislav - so we exchanged dynamic nature of language and sacrificed speed by doing the step 20 years back :-) |
btiffin 13-May-2007 [7928] | Ladislav; I hope you don't mind, but I put a link to %timblk.r in a lot of the rebol.org timing script documents. Check http://www.rebol.org/cgi-bin/cgiwrap/rebol/documentation.r?script=timeit.r#toc-4 for a sample. |
Terry 14-May-2007 [7929x2] | Any ideas on the best way to escape javascript as a Rebol string.. It's not uncommon to have double quotes, single quotes and curly braces in a single line ie: <a href="" onclick="$('mydiv').alpha({transparency:50%});"> Fade</a> |
FYI .. built a block with 1 million (random 1000000) integers then ran a forskip myblock 3 vs foreach[ a b c ] myblock forskip time: 0:00:02.828 foreach time: 0:00:00.046 | |
Tomc 14-May-2007 [7931x2] | time the while loop while you are at it (db chat sat 8:58) |
closer to the forskip time I would imagine | |
Volker 14-May-2007 [7933] | and a parse-rule. |
Anton 14-May-2007 [7934] | Terry, the reason is foreach is native and forskip is a somewhat heavier mezzanine which calls WHILE to do its work. See Henrik's comment above. |
Gregg 14-May-2007 [7935] | Can't you just put curly braces around the string Terry? |
Terry 14-May-2007 [7936] | um I can ;) didnt' realize you could nest curly braces |
BrianH 14-May-2007 [7937x2] | Keep your { and } balanced in your Javascript snippets. You can't escape { in strings, so you might need to have parts of your code in "" or use ^(7B) instead. |
Not being able to escape { in strings is a bug, by the way. | |
Volker 14-May-2007 [7939x2] | actually its possible from files, only console is broken >> load "{escape ^^{ please }" == "escape { please " |
a ^{ is enough of course, but must be escaped for the "" | |
Terry 15-May-2007 [7941x2] | ok.. so you store it using ^{ and ^} but how do you filter out the ^ later on? |
Using html special characters would make sense (or unicode) given the content is primarily web centric ie:{"hello" {world}} Then convert for rebol based string manipulation >> replace/all ie "{" "^(7B)" == {"hello" ^{world}} | |
Volker 15-May-2007 [7943x2] | The ^ is filtert out by the loader, in the string is only a { |
>> head insert/dup "" "{" 64 == {^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^{^... :) | |
Terry 15-May-2007 [7945] | yeah, but what happens when you send that to a web page? |
Oldes 15-May-2007 [7946x7] | I guess, it should give you same result as if you print it... |
>> print head insert/dup "" "{" 64 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | |
isn't this a little bit strange? | |
x: [tmp: copy [] loop 5 [insert tail tmp random 100] probe tmp tmp] reduce compose [(x)] | |
=== [[53 12 4 15 71] [] [53 12 4 15 71] [53 12 4 15 71]] | |
hmm... probably not... now i see that it's normal reduced result for: [ (tmp: copy [] ) (loop 5 [insert tail tmp random 100]) (probe tmp) (tmp)] | |
so forget it:-) maybe I should stop working today | |
Henrik 15-May-2007 [7953x2] | does anyone have a function to calculate the age of a person exactly? I need maximum precision in that his birthday is correct every time. |
including leap years | |
btiffin 15-May-2007 [7955] | There is a rebol.org script that prints age to the second. New user wrote it so it assumes you were born at midnight. %now.r Probably needs a pro touch up. |
Henrik 15-May-2007 [7956] | well, it simply subtracts dates |
Gregg 15-May-2007 [7957] | Where does it produce incorrect results? Do you have a good test case or two. I think stuff I've done is based on the same simple concept. |
Henrik 15-May-2007 [7958] | hmm... it looks like REBOL will do it right as long as you don't take leap years into account |
Maxim 15-May-2007 [7959x2] | the question is, how do handle people born on the 29th of feb. |
even if you have number of days, its quite hard to then figure out the number of years/days correctly... especially when displaying them. | |
Gregg 15-May-2007 [7961] | days-between: func [date-1 [date!] date-2 [date!]][ return date-1 - date-2 ] persons-age: func [ "Return a persons age, in years." b-day [date!] /precise "Include decimal portion of age." /days "Return result as how many *days* old the person is." /yrs-days "Return result as number of years and days (2 item block)." /on "Use alternate date instead of current date, to figure age." date /local result ][ date: any [date now] if days [return days-between date b-day] if precise [return (days-between date b-day) / 365.25] if yrs-days [return compose [(to-integer date - b-day / 365.25)(date - b-day // 365.25)]] ; otherwise, take away 1 year if their birthday hasn't come yet this year. return date/year - b-day/year - either any [ (date/month > b-day/month) all [ (date/month = b-day/month)(date/day >= b-day/day)]] [0][1] ] |
Henrik 15-May-2007 [7962] | the problem is to hit their birthdate correctly, so 38.9 turns to 39 exactly on their birthdate |
Gregg 15-May-2007 [7963] | round/down :-) |
Henrik 15-May-2007 [7964x3] | gregg, yes, but still leap year to take into account |
wow, it seems to do it correctly. at least for the dates tested here | |
gregg, is it yours? I need to credit it. | |
Gregg 15-May-2007 [7967] | Yes, it's mine. Well, either it's mine or I forgot to keep a credit for it, which I'm usually pretty good about. :-) |
older newer | first last |