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

[REBOL] Re: sort/scramble

From: carl::cybercraft::co::nz at: 24-Jan-2004 11:42

On 04-Jan-04, Hallvard Ystad wrote:
> Hi > I need a function that will make sure a block is _not_ sorted. > ex: >>> sort/scramble [ 1 2 7 7 7 4 9 f 3 h h h h 3e 54 5 4 k] >>> [ 1 h 2 7 h 4 9 f 3 h 7 3e 54 7 h 5 4 k]
Is that a real, in-use block? As I get an error with it...
>> blk: [ 1 2 7 7 7 4 9 f 3 h h h h 3e 54 5 4 k]
** Syntax Error: Invalid decimal -- 3e ** Near: (line 1) [ 1 2 7 7 7 4 9 f 3 h h h h 3e 54 5 4 k]
> Is this feasible without a lot of work? Would anyone happen to have > such a function in a drawer somewhere?
RANDOM can be used directly on blocks (and series). ie...
>> random [ 1 2 7 7 7 4 9 f 3 h h h h 3 e 54 5 4 k]
== [3 1 4 7 7 h h 5 3 h 2 7 54 k e f 9 4 h]
>> random [ 1 2 7 7 7 4 9 f 3 h h h h 3 e 54 5 4 k]
== [3 h 7 4 h 54 4 5 1 2 e 7 k h h 7 9 3 f]
>> random [ 1 2 7 7 7 4 9 f 3 h h h h 3 e 54 5 4 k]
== [9 4 h 5 3 4 7 2 7 7 3 h f 1 54 h e h k] It just depends on how you define unsorted... -- Carl Read