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

[REBOL] Re: sorting a serie ....

From: brett:codeconscious at: 19-Jun-2003 8:39

Hi Arnaud, There has been plenty responses answering your problem, I just want to add a little more detail on the reason the solutions work. 1) A block is an ordered sequence of values. 2) [a b c] is a block of three values. These value are of type word! *not integer!* 3) Words can indirectly express other values. The user guide says "An indirectly expressed value is unknown until it is evaluated." In overview, in your example you need to sort [255 1 -1] which is a result of the evaluation of: REDUCE [a b c]. Sort [red green blue] sorts the three block values - words - using their spelling as you have discovered. Looking at some of the solutions. Max suggested: print sort compose [(a) (b) (c)] He was creating the [255 1 -1] block first using Compose. Max and others suggested print sort reduce [a b c] As noted above Reduce creates the [255 1 -1] that is subsequently sorted. Tim suggested: print sort/reverse [a b c] This works because Print implicitly carries out a REDUCE. Hope that was useful! Brett.