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

World: r3wp

[Core] Discuss core issues

Gordon
5-Nov-2005
[2709x2]
I'm not sure.  I don't think so but I can't remember why not.
Something about reordering the records makes sort/skip not suitable.
BrianH
5-Nov-2005
[2711]
(Back to slicing briefly) REBOL already has functionality equivalent 
to slicing as copy-of-subsection, so this would be better represented 
as a very simple mezzanine function that does the work. If you mean 
slicing as reference-to-subsection-in-place, that would be worth 
adding new support for. Something like:

slice!: make object! [start: end: none]

slice: func [[catch] s [series!] /from b [integer!] /to e [integer!] 
/len l [integer!]] [
    b: either from [at :s b] [:s]
    e: case [
        to at :s e
        len skip :b l
        true tail :s
    ]
    if greater? index? :b index? :e [to: :e e: :b b: :to]
    make slice! [start: b end: e]
]
Sunanda
5-Nov-2005
[2712]
sort/skip --- I get you -- like it's not easy to sort on the 2-digit 
numbers here:
sort/skip [99 10 2       98 11 5        97 12 4] 3
But it is possible with /all and a parameter into the function
Gordon
5-Nov-2005
[2713x2]
Lots to think about and try.  Thanks a bunch guys for your help.
When I get the function rewritten, I will upload it to the library.
BrianH
5-Nov-2005
[2715x2]
Sunanda, do you mean sort on the second field? Try passing an integer 
or block of integers to the compare refinement of sort.
Rather than a comparator function.
Sunanda
5-Nov-2005
[2717]
I mean the middle of the three fields, sorting a 3-field record:
  sort-func: func [a b] [return a/2 < b/2]

  sort/skip/all/compare [99 10 2       98 11 5        97 12 4] 3 :sort-func
== [99 10 2 98 11 5 97 12 4]
BrianH
5-Nov-2005
[2718x2]
sort/skip/compare data 3 2
The 2 passed to /comapare means the second field.
Sunanda
5-Nov-2005
[2720]
Clever -- I didn't know that. Thanks. 

But I tend to use the compare function to get stable sorts.  The 
[x < y]  was just  to shorten the example.
BrianH
5-Nov-2005
[2721x3]
(sorry, /compare)
What, sort isn't stable?
I've always found it to be so.
Sunanda
5-Nov-2005
[2724]
Not unless you return +1 ,0,  -1
Returning true/false is not guaranteed to be stable
Gordon
5-Nov-2005
[2725]
Sort hasn't crashed on me if that's what you mean by unstable.
BrianH
5-Nov-2005
[2726]
It's not.
Sunanda
5-Nov-2005
[2727x2]
Stable is to do with the order in which duplicate keys are returned.
Looks like stable camwe with /core 2.5
http://www.rebol.com/docs/core25.html
Graham
5-Nov-2005
[2729x3]
Any mathematicians here ?
On this page : http://www.mja.com.au/public/issues/178_03_030203/sim10248_fm.html#CHDBFAJE

There is this formula


Absolute CVD risk can be calculated from the formula: Probability 
of CVD = 1/(1 + e- k ), where k = – 8.65 + 0.057*age – 0.61*sex + 
0.749*antihypertensive medication + 0.008*systolic blood pressure 
+ 0.458*smoking + 0.18*cholesterol – 0.234*HDL cholesterol + 0.857*diabetes.
what does e stand for ?  Is that some type of log calculation ?
BrianH
5-Nov-2005
[2732]
The exp function in REBOL?
Graham
5-Nov-2005
[2733]
It's a long time since I did any high school math :(
BrianH
5-Nov-2005
[2734x2]
cvd: divide 1 1 + exp negate (-8.65 + (0.057 * age) - (0.61 * sex) 
+ (0.749 * ahm) + (0.008 * sbp) + (0.458 * smo) + (0.18 * cho) - 
(0.234 * hdl) + (0.857 * dia))
Based on the formula on the page there.
Izkata
5-Nov-2005
[2736x2]
e is a constant - log is base 10 by default, ln (natural log) is 
base e
(ln = log-e in Rebol)
BrianH
6-Nov-2005
[2738]
The exp function calculates e raised to the exponent of the argument 
to the function. If you look on the the web page he is referencing, 
you will see that where he puts e -k, the -k is in superscript, indicating 
that it is to be treated as an exponent.
Graham
6-Nov-2005
[2739x2]
Great. My function gives the same result as yours.
Seems however, that sex is 1 for female, and 0 for male for this 
to work ( being male confers a higher risk ).
Louis
8-Nov-2005
[2741]
Does now/time give military time?
Geomol
8-Nov-2005
[2742]
Almost, no leading zero. Try: now/time + 12:00
Geomol
10-Nov-2005
[2743]
If I have an object with a function:
o: make object! [f: func [] [print "Hello World!"]]

Is there a shorter/faster way to get the function without evaluating 
it than:
get in o 'f
?
DideC
10-Nov-2005
[2744]
Shorter?
g i o 'f
:)
Geomol
10-Nov-2005
[2745]
lol :P
Terry
12-Nov-2005
[2746]
Is there some way to send the html of a web page to the Rebol 'browse' 
function without actually writing the html file?
Graham
12-Nov-2005
[2747x2]
the browser has to read a file...
or  stream of data.
Terry
12-Nov-2005
[2749x3]
here's a quick demo..
rebol []

theTOC: ask "Table of contents (seperate with <p></p> tags): "
theHeader: ask "Header: "
theNumOfBars: ask "Number of chart bars: "
outputPath: ask "Save path (with trailing / ie: c:/): " 


getTemplate: read http://o7o.org/files/aflax/examples/barchart/barchart.html

getSWF: read/binary http://o7o.org/files/aflax/examples/barchart/aflax.swf

replace/all getTemplate "$TOC" theTOC
replace/all getTemplate "$theHeader" theHeader
replace/all getTemplate "$numOfBars" theNumofBars

write to-rebol-file join outputPath "barExample.html" getTemplate
write/binary to-rebol-file join outputPath "aflax.swf" getSWF
browse to-rebol-file join outputpath "barExample.html"
oops wrong group
DideC
13-Nov-2005
[2752]
Yes, you can "browse http://127.0.0.1:123456" and have a small server 
to send the page to the browser.
Volker
16-Nov-2005
[2753x2]
is it possible to set the args of an error explicitely, instead of 
giving a string?
found it: http://www.rebol.com/docs/core23/rebolcore-17.html#section-5
JaimeVargas
16-Nov-2005
[2755]
What will be the closest to lisp CONS method in rebol?
Volker
16-Nov-2005
[2756]
thats for building lists? insert/append ?
JaimeVargas
16-Nov-2005
[2757]
Is for building list using mutually recursive funcs.
Volker
16-Nov-2005
[2758]
and at the end you have something linear, so you could use block! 
or list! ?