World: r3wp
[Core] Discuss core issues
older newer | first last |
Tomc 14-May-2007 [7932] | 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 [7967x2] | 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. :-) |
It has my birthday in the tests, so I'm guessing I wrote it. | |
Henrik 15-May-2007 [7969x2] | seems to be missing by a day here... |
oh, well. I'll see what the customer says :-) many thanks! | |
Gregg 15-May-2007 [7971] | Send me test cases that fail and I'll try to make it right. |
Henrik 15-May-2007 [7972] | I will. Perhaps you should add it to the code snippet check list? |
Gregg 15-May-2007 [7973] | Feel free. |
Henrik 15-May-2007 [7974] | done |
Gregg 15-May-2007 [7975] | Thanks. |
Geomol 17-May-2007 [7976x2] | Is there a loader for Targa images (.tga)? Does it require a license to support the Targa format? Does anybody know? |
I need a REBOL->C converter. I spend hours programming in C to do something, it'll take minutes to do in REBOL. | |
Sunanda 17-May-2007 [7978] | R3 runs as a DLL......Car showed his basic development C script at DevCon. It was abouy 12 lines of C, the heart of it being a call to REBOL, passing a string to be DOne. That may be all you need to run REBOL from C with R3. |
Geomol 17-May-2007 [7979x2] | It's not actually that, I'm after. In this project I need all the speed, I can get, so I do it in C, but it's a lot of time spent. I was thinking about a dialect in REBOL, that can be converted to C and compiled. That way it should be possible to produce C source a lot faster, than I do now. |
Something like: [img: load-image/tga %gfx/image.tga] The converter should then convert that to a lot of C source, that I can compile with gcc. | |
Rebolek 17-May-2007 [7981] | I wrote a dialect that is converted to C and compilable. It just covers basic math operations though, as that was all I needed. No pointers stuff and so on. But if you're interested to expand it, I can publish it somewhere (not sure how ugly the code is, didn't touch that in year or so). |
older newer | first last |