Hi Mat & Carl,

> Hmmm.  A quick test of that didn't work for me.  However, there's a
> word to do that.  It's called 'unique. (: ...
>
> >> unique stuff
> == ["fire" "water" "air"]

Knew there was a more suitable word than 'union.

Anyway, had a go refining the function.  This one is better because:

o It uses less words.
o It works with blocks that include integers.  Which itself is interesting -

Try this at the console:

x: [1]
x: block-stats x  ; keep repeating this line

Try starting 'x at [1 2] or [1 2 3].  They all come to the same conclusion.
(well, I found it interesting :o)

- Chris

--
REBOL []

block-stats: func [
    in-blk [block!]
    /local num num-blk out-blk
][
    out-blk: unique in-blk
    num-blk: copy []
    loop length? out-blk [append num-blk 0]

    foreach item in-blk [
        num: index? find out-blk item
        change back skip num-blk num num-blk/:num + 1
    ]

    while [not tail? out-blk][
        insert next out-blk first num-blk
        out-blk: skip out-blk 2
        num-blk: next num-blk
    ]

    head out-blk
]

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to