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

[REBOL] Re: Algorithm challenge: compacting intege...

From: D::Weyand::gmx::de at: 30-Jan-2007 11:59

No problems with those versions of compact here...
>> compact copy [1 2 3 10 11 99 101 2000 2001 2002 2003 2004]
== [1x3 10x2 99 101 2000x5]
>> compact copy []
== []
>> compact copy [1]
== [1]
>> compact copy [2]
== [2]
>> compact copy [3]
== [3]
>> compact copy [1 2]
== [1x2]
>> compact copy [1 2 3]
== [1x3]
>> ?? compact
compact: func [ blk [block!] /local b n x val rc ][ rc: make list! blk loop length? rc [ either tail? b: next rc [ break ] [ x: val: first rc all [while [(val: val + 1) = pick b 1] [b: remove b] change rc add x * 1x0 val - x * 0x1] ] rc: next rc ] to block! head rc ]
>>
Which version of REBOL do you use? Regards Dirk -------- Original-Nachricht -------- Datum: Mon, 29 Jan 2007 16:43:50 +0800 Von: Peter Wood <pwawood-gmail.com> An: rebolist-rebol.com Betreff: [REBOL] Re: Algorithm challenge: compacting intege...
> Dirk > > The script chokes on a single entry block: > >> compact [1] > ** Script Error: Out of range or past end > ** Where: compact > ** Near: to block! head rc > > It is okay with [] and [1 3]. > > It looks as though your earlier submission did too. > > Regards > > Peter >
-- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail