Hi Sam,

Take a look at the 'prune' word in the hashtables vocabulary, it does  
exactly what you want but it runs in O(n) time because it uses a  
hashtable to track which elements have already been added.

Slava

On 6-Oct-07, at 1:48 PM, Samuel Tardieu wrote:

> I was in the need of a "unique" word which, given a sequence, builds a
> new sequence of the same kind with unique elements of the input
> sequence while keeping the same order (only subsequent duplicate
> elements must be ommited). I ended up with:
>
> : unique ( seq -- newseq )
>     [
>         dup length <vector> tuck
>         dup [ member? not ] curry
>         swap [ push-if ] curry curry each
>     ] keep like ;
>
> Is that an abuse of curry (three of them?) How would you write it?
>
>  Sam
>
>
> ---------------------------------------------------------------------- 
> ---
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a  
> browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to