there may already be a better way to do this in the euphoria 4 standard lib or in the archive, but I have used this a few times and it just works. assume it has not tested more than appears here.

include std/sequence.e 
-- Input a sequence, list of lines for example. 
-- Output the list with no duplicates. 
-- Used most often with something like sul = sort(unique(list)) 
function unique(sequence list) 
  return remove_dups(list, RD_INPLACE) 
end function 
ifdef UNITTEST then 
    include std/unittest.e 
    include std/sort.e 
    sequence test_source = "DAFBAGCFE" 
    test_equal("plain unique" 
         ,"DAFBGCE",  unique(test_source)) 
    test_equal("sorted unique" 
         ,"ABCDEFG",  sort(unique(test_source))) 
end ifdef  


Quick Links

User menu

Not signed in.

Misc Menu