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

World: r3wp

[Rebol School] Rebol School

Geomol
8-Feb-2009
[1724]
In the classes in astronomy, we're taught a language called IDL to 
reduce scientific data and make images and diagrams. I often just 
use REBOL directly to make the diagrams. I've wanted many times to 
make a library of routines or a plotting application in REBOL, but 
haven't had the time yet. Maybe some day.
Anton
8-Feb-2009
[1725x2]
When it comes across a lit-word!, however, it reduces it to the word! 
of the same spelling.
This is how I think of it:

	lit-word!  -->  word!  -->  value
kib2
8-Feb-2009
[1727x2]
Anton: ok, that's clearer now.
Geomol: is creating a plotting dialect that hard ?
Steeve
8-Feb-2009
[1729x2]
try this Kib:
>> a: 2
>> reduce [a]
>> reduce ['a]
and
>> reduce reduce ['a]
Henrik
8-Feb-2009
[1731]
I wouldn't mind being able to set 3-4 months aside to create a complete 
graphing dialect.
kib2
8-Feb-2009
[1732]
Steeve: ok i've tried. But why the reduce output is a block ?
Anton
8-Feb-2009
[1733]
(kib2: yes, creating a plotting dialect is hard. It must be - I tried 
creating a general plotting function. There are many types of chart/graph 
to support.)
Geomol
8-Feb-2009
[1734]
kib, it's probably not hard, maybe take a bit of work to make it 
really slim and clever. I just have a ton of projects in the air 
all the time, so I didn't come to it yet.
kib2
8-Feb-2009
[1735]
Geomol: not as much as Carl !
Steeve
8-Feb-2009
[1736]
Kib because the input of reduce is a block
Anton
8-Feb-2009
[1737x2]
Try this:
	reduce ['print join "bon" "jour"]
That is simply how reduce works. If you want a single value output, 
then use DO, which returns the last evalated value in the block.
	do ['a]
kib2
8-Feb-2009
[1739x2]
Anton: funny
in fact it's logical : everything is a block.
Henrik
8-Feb-2009
[1741]
REDUCE is one of several block manipulation functions. It evaluates 
anything that can be evaluated inside a block.
Steeve
8-Feb-2009
[1742x2]
even, you can do 
>> reduce 'a
ahahah
Henrik
8-Feb-2009
[1744]
REDUCE is not restricted to blocks.
Anton
8-Feb-2009
[1745]
Yes, if you type something in the console, eg:

	print 1 + 2


you can imagine that it takes the string "print 1 + 2", LOADS it 
into a block, [print 1 + 2], then DOes it.
kib2
8-Feb-2009
[1746]
Steeve: yes, i've tried, but it's limited to the word behind reduce 
then ?
Steeve
8-Feb-2009
[1747]
not now, but in the past, it was
Anton
8-Feb-2009
[1748]
DO is like REDUCE, in that it evaluates every item in the block, 
except DO does not create and store results in a new block - it just 
returns the last value.
Steeve
8-Feb-2009
[1749]
yes Kib, blocks are mainly used to pass several value
kib2
8-Feb-2009
[1750]
understood, now the question is what we cannot do in Rebol ?!
Anton
8-Feb-2009
[1751x2]
You can't really say that in rebol everything is a block, but you 
can say everything is *in* a block. Most rebol code is found in blocks. 
Blocks rule as the container of choice in the rebol universe!
What we cannot do in rebol:
Steeve
8-Feb-2009
[1753]
i will say, what we cannot do without pain. All is possible but some 
are painfull
Anton
8-Feb-2009
[1754]
- Create references to parts of datatypes. Eg. Make a variable which 
aliases the y component of a pair!
Steeve
8-Feb-2009
[1755]
Hum, we can with tiny functions accessors, the drawback is that it's 
more slow than a real reference
Anton
8-Feb-2009
[1756]
A pair! is a datatype which looks like a series, but is unfortunately 
(for this case) a scalar. That means any modification causes the 
whole pair to be copied.
kib2
8-Feb-2009
[1757]
I think I've found a good exercice...if only the following is true 
: Rebol seems to handle prefix notation
Geomol
8-Feb-2009
[1758]
Operators can be prefix or infix

>> 2 + 3
== 5
>> + 2 3
== 5
Anton
8-Feb-2009
[1759]
Steeve, yes, you can do that, but then if other people want to use 
your code, they must use the accessors you have written, which effectively 
expands the language.
kib2
8-Feb-2009
[1760]
really strange : "+ 2 3" returns 5, but "- 2 3" returns 3
Anton
8-Feb-2009
[1761]
The - there is actually unary.
Geomol
8-Feb-2009
[1762]
Yes, strange!
Anton
8-Feb-2009
[1763]
A negate.
Geomol
8-Feb-2009
[1764x2]
ah yes. :-D
lol
Anton
8-Feb-2009
[1766x2]
It's the same as typing only  "2 3"
The 2 is evaluated (to 2), then the 3 is evaluated and returned, 
because it's last.
Steeve
8-Feb-2009
[1768]
-2 3
 instead
kib2
8-Feb-2009
[1769]
Anton: that's it. So then  "+ 2 -3"
Anton
8-Feb-2009
[1770x3]
(Steeve, yes, more similar.)
- is the (only?) operator which cannot be used infix.
Sorry, that's an incorrect statement.
Geomol
8-Feb-2009
[1773]
To get list of operators:

>> ? op!