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

World: r3wp

[Rebol School] Rebol School

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!
Steeve
8-Feb-2009
[1774]
Kib but for our sake, there is an infix version of - operator: subtract
Geomol
8-Feb-2009
[1775]
You mean prefix.
Anton
8-Feb-2009
[1776x2]
- cannot be used as binary prefix operator, unlike the others + * 
/
Yes.
kib2
8-Feb-2009
[1778]
Steeve : thanks, i was just lookin for something like that
Steeve
8-Feb-2009
[1779]
i don't like this name by the way, Carl should have renamed it: sub, 
since long time ago
Anton
8-Feb-2009
[1780]
I never use SUBTRACT because it's too long ! :-)  I always just use 
parens to allow me to use -, even if evaluation is slower.
kib2
8-Feb-2009
[1781]
Steeve : +1
Anton
8-Feb-2009
[1782]
Using parens, it's more clear this way.
Steeve
8-Feb-2009
[1783x2]
sub suuuuuuuuuuuuuuuub ;-)
like in rebcode
Geomol
8-Feb-2009
[1785x4]
Most operators have prefix only twins (that are called actions). 
Like: equals? is the twin of =
equal?
(without s)
multiply, add, subtract, divide, remainder, lesser?, lesser-or-equal?, 
not-equal?, equal?, strict-equal?, same?, greater?, greater-or-equal?
kib2
8-Feb-2009
[1789]
Geomol: power
Steeve
8-Feb-2009
[1790]
beware with same? it's not really a math operator
Geomol
8-Feb-2009
[1791x4]
If you prefer SUB instead of SUBTRACT, just do this in the beginning:

sub: :subtract
ah yes, POWER aslo.
*also*
I think, SAME? is like =?
Steeve
8-Feb-2009
[1795x2]
yes but it's used for serie manipu
or objects, not for maths
Geomol
8-Feb-2009
[1797]
>> [a b c] = [a b c]
== true
>> [a b c] == [a b c]
== true
>> [a b c] =? [a b c]
== false
Steeve
8-Feb-2009
[1798]
oh my.... you should not bother Kib with same? too early ;-)
Geomol
8-Feb-2009
[1799x4]
lol, he's bright, so he get it.
>> 1 = 1.0  
== true
>> 1 == 1.0
== false
Remember, if you wanna know more about operators like =, == and =?, 
just use ? to ask about them:

>> ? =?
It's fun doing these REBOL School sessions. It helps refresh the 
memories of us more experienced coders. It's hard (impossible) to 
remember all the corners of REBOL.
kib2
8-Feb-2009
[1803]
Geomol: in the last case 1 and 1.0 are different beasts because the 
first is integer and not the other, that's it ?