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

World: r3wp

[Rebol School] Rebol School

kib2
8-Feb-2009
[1896]
I don't like the implementation, but the parse rules are worth reading
Geomol
8-Feb-2009
[1897]
For debugging, you'll find PROBE to be very usefull. You can put 
it in about anywhere in your code, and it will just work as without 
PROBE. Examples:

>> square-root probe 4 * 8
32
== 5.65685424949238
>> read probe join http:// "www.rebol.com"
http://www.rebol.com
connecting to: www.rebol.com
== {<html>
...
kib2
8-Feb-2009
[1898]
nice, thanks. Now, I'm looking for something like hashtables (key-value). 
Is there something special, or do I need to use blocks ?
Geomol
8-Feb-2009
[1899x3]
>> if 1:00 > probe now/time [print "Go to bed!"]
0:05:35
Go to bed!
Try
>> ? hash
This will create a hashtable, that works like a block, but is faster:

>> table: make hash! [a 1 b 12 c 4 d 65]
kib2
8-Feb-2009
[1902x2]
Geomol: sorry, you can go to bed
Geomol: and thanks a lot for your help
Geomol
8-Feb-2009
[1904x2]
lol :-)
it's ok, I'll go to bed in a moment.
You can read a short intro to hash tables here: http://www.rebol.com/docs/core23/rebolcore-16.html#section-2.5
kib2
8-Feb-2009
[1906x4]
I just discovered this:
markup: ["**" "strong" "//" "em" "__" "u" "--" "del" "^^" "sup" ".." 
"sub"]
foreach [bal html] markup [format text bal html]
where format is a function I've written.
Geomol
8-Feb-2009
[1910]
REBOL has a build-markup function.
kib2
8-Feb-2009
[1911x2]
really ?
So mine overwrited Rebol's one ?
Geomol
8-Feb-2009
[1913x3]
It may have changed in recent version. Let me check...
You have build-tag, to-tag and build-markup.
Functions to help you make markup text.
Izkata
8-Feb-2009
[1916]
Does hash! work with nested blocks?
Geomol
8-Feb-2009
[1917x2]
>> build-tag [a b 1]
== <a b="1">
Izkata, I don't know.
kib2
8-Feb-2009
[1919x4]
powerful.
a: 1
build-markup "toto<%a%>"
so that's string interpolation too :)
Izkata
8-Feb-2009
[1923]
just tested, looks like it doesn't they way I mean:

>> type? second Z: make hash! [One [F1 {Hi} F2 {Bye}] Two [F1 {Yes} 
F2 {No}]]
== block!
However, this works:
>> Z/2: make hash! Z/2
Geomol
8-Feb-2009
[1924]
It seems, it does, if you do it like this:


>> t: make hash! compose [a (make hash! [a 43 b 34]) b (make hash! 
[a 34 b 87])]
== make hash! [a make hash! [a 43 b 34] b make hash! [a 34 b 87]]
>> type? t/2
== hash!
>> t/b
== make hash! [a 34 b 87]
>> t/b/a
== 34
Izkata
8-Feb-2009
[1925]
yeah
Geomol
8-Feb-2009
[1926]
kib, yes
Izkata
8-Feb-2009
[1927]
When you mentioned it was faster, I got curious, as I need speed 
for some data mining algorithms I'm implementing in Rebol for a class
Geomol
8-Feb-2009
[1928x4]
It states in the documentation, that using hash can increase the 
speed hundreds of times, if you have large tables.
A simple timing function to test performance:

time: func [:f /local t][
    t: now/time/precise
    do f
    now/time/precise - t
]
>> time [loop 1000000 [pi ** 2]]
== 0:00:00.468
I've never used build-markup, I just realize.
Janko
8-Feb-2009
[1932]
it is normal that hash! will only hash "keys" of assoc on first level, 
if you want on sublevels you can iterate the list and turn it into 
hashes acordingly .. if you have a lot of data hash is a lot faster 
650x in this test http://www.rebol.com/article/0020.html
kib2
8-Feb-2009
[1933]
Geomol: funny, you can test any function like this, it's cool.
Geomol
8-Feb-2009
[1934]
kib, yes :-)
Janko
8-Feb-2009
[1935]
kib2: technically , that is not a function but a block of code (which 
is very usefull) :) .. sorry to be a smartass
kib2
8-Feb-2009
[1936]
Is there any tool to edit and view  at the same time rebDoc files 
? I've an idea...
Geomol
8-Feb-2009
[1937x2]
kib, like "Easy VID"? Go to ViewTop and REBOL.com/Demos/Easy VID

When you read a page, you can click the code and see how it evaluate.
The whole Easy VID is a 15.1 kb script. You can right-click an icon 
on the ViewTop to see source, size, etc.
kib2
8-Feb-2009
[1939x4]
Geomol: no, I mean something to write documentations for a rebol 
lib.
but Easy VID is really great (but I don't like the fonts)
2 secs, I'm making a screenshot
Like this : http://tinyurl.com/cfetnn(that's the tool I've build 
to make my posts on my blog)
Geomol
8-Feb-2009
[1943x2]
Ok, got it. Carl use MakeDoc to make his documentation, I use NicomDoc 
(my version of MakeDoc). I don't know of a tool, that can show you 
the result, while you type.
kib, so that's a good project for you! :-)
kib2
8-Feb-2009
[1945]
Geomol: I think so :) But for the moment it's in Python (and Qt4). 
Is there any browser-like widget in the Rebol GUI ?