Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: R: Re: reduce second [one two]

From: santilli:gabriele:gm:ail at: 14-Jan-2009 11:39

[Also sent privately because Ecartis does not like me anymore] On Wed, Jan 14, 2009 at 7:47 AM, Giuseppe Chillemi <gchillemi-aliceposta.it> wrote:
> Instead "second [one two]" returns 'TWO rather than TWO which is a thing you > don't notice in the consolle as the ouput is TWO in both situations.
It's the opposite:
>> second [one two]
== two
>> type? second [one two]
== word!
>> two
== 2
>> type? two
== integer!
>> 'two
== two
>> type? 'two
== word!
>> type? second ['one 'two]
== lit-word! two is a word!. When a word is evaluated (DO or REDUCE), it produces the value it is set to. "'two" is a lit-word!. When a lit-word is evaluated (DO or REDUCE), it produces the respective word value. You are not getting a lit-word from second, but a word, which is indeed the second value in the block. But, if you type:
>> reduce two
== 2 the REDUCE function is not getting a word as argument, it is getting the integer 2, because the word is evaluated BEFORE being passed to REDUCE. Notice above how "two" produces "2" and how "type? two" returns "integer!" and NOT "word!". HTH, Gabriele.