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

World: r3wp

[Core] Discuss core issues

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! ?
JaimeVargas
16-Nov-2005
[2759]
I tried using reduce but it didn't quite work. Append failed completely. 
Maybe I need a way to keep a block.
Volker
16-Nov-2005
[2760]
do you have a lisp-example?
JaimeVargas
16-Nov-2005
[2761x6]
Yes.
(define subst
  (lambda (new old slist)
    (if (null? slist)
        '()
        (cons 
         (subst-in-symbol-expression new old (car slist))
         (subst new old (cdr slist))))))

(define subst-in-symbol-expression
  (lambda (new old se)
    (if (symbol? se)
        (if (eqv? se old)
            new
            se)
        (subst new old se))))

(subst 'a 'b '((b c) (b () d)))
== ((a c) (a () d))
Here is my approach in rebol.
sub-sb: func [new old slist][
    either empty? slist [
        []
    ] [
        reduce [
            sub-sb-in-symbol new old slist/1 
            sub-sb new old next slist 
        ]
    ]
]

sub-sb-in-symbol: func [new old se][
    either word? se [
        either :se = :old [:new] [:se]
    ] [
        sub-sb new old se
    ]
]
>> sub-sb 'a 'b [[b c] [b [] d]]
== [[a [c 
            []
        ]] [[a [
                [] [d 
                    []
                ]
            ]] 
        []
    ]]
Volker
16-Nov-2005
[2767x2]
So not linear, but a tree. And you use blocks as lisp-pairs.
Do you need a rebol-version for this problem, or general a cons-emulation?
JaimeVargas
16-Nov-2005
[2769]
I think I can contruct CONS myself. But I was wondering if we could 
do it just with rebol constructs. I would also like to see you CONS.
Volker
16-Nov-2005
[2770x7]
In this case i would not cons a new tree, but change the old (or 
a copy of it).
if i understand right, we could use a block for a lisp-pair, and 
'first and 'second for car/cadr ?
and a list (a b c) would look like
 [a [b [c nil] ] ]
Have to remember my little bit lisp..
http://www.rattlesnake.com/intro/cons.html#cons?
something like
cons: func[a b][
 reduce[ first a  b  ]
]
cons: func[a b][ reduce[ first a  b  ] ]
 probe cons[a none] cons [b none ][c none]
== [a [b [c none]]]
and 
(cons 'a (cons 'b '(c)))
== (a b c)
JaimeVargas
16-Nov-2005
[2777x2]
This is my cons it works well. I think there is a problem with yours. 
cons: func [
	[catch] car cdr [series!]
][
	either empty? cdr [
		either all [series? car empty? car] [
			[]
		][
			reduce [car]
		]
	][
		head insert tail reduce [car] cdr
	]
]
>> cons [a b c] [d e]
This is a list of test from lisp.

> (cons 'a '())
(list 'a)
> (cons '() '())
(list empty)
> (cons '() 'a)
cons: second argument must be of type <list>, given empty and 'a
> (cons '(a b c) 'a)

cons: second argument must be of type <list>, given (list 'a 'b 'c) 
and 'a
> (cons '(a b c) '(d e))
(list (list 'a 'b 'c) 'd 'e)
Volker
16-Nov-2005
[2779x4]
I guess i represent lisp-nodes differnetly, and maybe wrong.
for me a lisp-node has always two values, there is no empty one. 
So i use always a block of length 2.
btw here is a rebol-version of subst:
l: first[ ((b c) (b () d)) ]
subst: func[l old new][
 forall l[
  either any-block? l/1 [
   subst l/1 old new
  ][
   if old == l/1 [ l/1: new ]
  ]
 ]
 l
]
probe l
probe subst l 'b 'a