Tuples versus Deciamls
[1/10] from: behrangsa::yahoo::com at: 12-Jan-2004 16:47
Hi
Is, for example, 1.1 a tuple or a decimal?
Thanks.
[2/10] from: atruter:labyrinth:au at: 13-Jan-2004 12:12
> Is, for example, 1.1 a tuple or a decimal?
Decimal, a tuple must have at least three components. Perhaps pair! is
what you want? ;)
Regards,
Ashley<
[3/10] from: cybarite:sympatico:ca at: 12-Jan-2004 20:43
It is easy to find somethings out from the console:
type? 1.1
type? 1.1.2
If it is an object then you can probe it to find out information:
a: make object! [b: "test" c: 12 d: 1.877777]
probe a
probe a/d
type? a/d
[4/10] from: gerardcote:sympatico:ca at: 12-Jan-2004 21:12
Hi again,
Without knowing much I think 1.1 is a decimal but nevertheless
it can be used for both datatypes. However you'll have to use
the 'to-tuple word to ask REBOL to convert the decimal
to the second one as is :
my-tuple: to-tuple 1.1
print type? my-tuple
May be others can help better,
Gerard
[5/10] from: AJMartin:orcon at: 24-Jan-2004 11:49
Behrang wrote:
> Is, for example, 1.1 a tuple or a decimal?
Let's ask Rebol:
>> type? 1.1
== decimal!
According to Rebol, 1.1 is a decimal value.
--
Andrew J Martin
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://Valley.150m.com/
[6/10] from: gerardcote:sympatico:ca at: 12-Jan-2004 21:15
You were right Ashley,
REBOL needs at least 3 components.
I never tried before but it seemed to be so natural ...
in fact REBOL fooled me this time but I will remember the lesson
Next time I will try before submitting my answer!
Regards,
Gerard
[7/10] from: behrangsa::yahoo at: 12-Jan-2004 18:53
Hi
The Docs and Tutorials are awesome compared to many
other languages/tools/compilers docs but are very
informal.
In the section about the tuples in quickstart it's not
stated that a tuple must at least have 3 elements. So
I said to myself "there should be some ambiguity
between decimals and tuples" although I was sure that
I'm wrong.
Anyawys, thanks for the answers.
[8/10] from: greggirwin:mindspring at: 12-Jan-2004 21:25
Hi Behrang,
BS> In the section about the tuples in quickstart it's not
BS> stated that a tuple must at least have 3 elements.
And they can have up to 10 elements.
BS> So I said to myself "there should be some ambiguity
BS> between decimals and tuples" although I was sure that
BS> I'm wrong.
Lexical space is very tight in REBOL, so once you get used to the
rules that apply to the different datatypes you'll be in good shape.
There aren't too many confusing things, but there are a few. One of
the biggest things that you can do to confuse yourself (and others) is
is coerce values to other types. Note, that I'm not saying it's a bad
thing, or that you should never do it but, when you do, you can end up
with values that don't match REBOL's lexical rules. e.g.
>> x: to issue! "abc def"
== #abc
>> print mold x
#abc
>> last x
== #"f"
Here, coercing a string containing a space to an issue! works
internally, but PRINT and the console output don't show it.
-- Gregg
[9/10] from: carl:cybercraft at: 24-Jan-2004 11:49
On 13-Jan-04, Gerard Cote wrote:
> You were right Ashley,
> REBOL needs at least 3 components.
<<quoted lines omitted: 3>>
> Regards,
> Gerard
Actually, you were right to say you can force a 2 component tuple
Gerard, as while this doesn't work...
>> t: to-tuple 1.1
** Script Error: Invalid argument: 1.1
** Where: to-tuple
** Near: to tuple! :value
this does...
>> t: to-tuple "1.1"
== 1.1.0
and despite the third number displayed there, it is a two component
tuple...
>> length? t
== 2
>> t/1
== 1
>> t/2
== 1
>> t/3
== none
As you say - test first - and keep testing till you get the answer you
want. ;)
> ----- Original Message -----
> From: "Ashley Trüter" <[atruter--labyrinth--net--au]>
<<quoted lines omitted: 6>>
>> Regards,
>> Ashley
--
Carl Read
[10/10] from: atruter:labyrinth:au at: 14-Jan-2004 0:34
>>> t: to-tuple "1.1"
> == 1.1.0
Interesting. Taken to extremes:
>> t: to-tuple "1"
== 1.0.0
>> length? t
== 1
>> t: to-tuple ""
== 0.0.0
>> length? t
== 1
>>
but how usefull is all this? ;)
Regards,
Ashley<
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted