Paste: Using sequences in locals

Author: tgunr
Mode: factor
Date: Sat, 6 Dec 2014 21:22:03
Plain Text |
:: uniqueIP ( seq -- uniqueseq )
    { } :> collection!
    { } :> uniques!
    seq [ :> item
        item getIP :> ip
        ip uniques member?
          [ uniques ip suffix  :> uniques!
            collection item suffix  :> collection!
          ] unless
    ] each
    collection
    ;

Annotation: Correced

Author: tgunr
Mode: factor
Date: Sat, 6 Dec 2014 22:01:26
Plain Text |
:: uniqueIP ( seq -- uniqueseq )
    V{ } :> collection!
    V{ } :> uniques!
    seq [ :> item
        item getIP :> ip
        ip uniques member?
          [ uniques ip suffix!  :> uniques
            collection item suffix!  :> collection
          ] unless
    ] each
    collection
    ;
        

Annotation: Corrected

Author: tgunr
Mode: factor
Date: Sat, 6 Dec 2014 22:08:21
Plain Text |
! walk thru list and for each item compare to items in uniques list
! if not in list list, add compare value and item to list
! when done, should have one-to-one corresponding lists, return the collected items

:: uniqueIP ( seq -- uniqueseq )
    V{ } :> collection!
    V{ } :> uniques!
    seq [ :> item
        item getIP :> ip
        ip uniques member?
          [ uniques ip suffix!  :> uniques
            collection item suffix!  :> collection
          ] unless
    ] each
    collection
    ;

New Annotation

Summary:
Author:
Mode:
Body: