Historical SnippitUnique, Revision 1

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/unittest.e
--~ with define UNITTEST




include std/sets.e
--**
-- input a sequence, list of lines for ex.
-- output the list in no particular order with no duplicates
-- used most often with something like sul = sort(unique(list))
-- this could/should be made more robust.
--
function unique(sequence list)
    set slist = sequence_to_set(list)
   return slist --works for now
end function



ifdef UNITTEST then
    set_test_verbosity(TEST_SHOW_ALL)

    test_equal("sorted unique"
         ,"ABCDEFG",  sort(unique("AABCDEFFG")))

    test_report()

end ifdef 

Search



Quick Links

User menu

Not signed in.

Misc Menu