RELATED TAGS
The remove_dups()
method is part of the e.sequence
, a standard Euphoria library module. It performs a basic operations on sequence variables.
The remove_dups()
function loops through a sequence and returns values from such a sequence.
It does this by checking for a duplicate value in such a sequence and returns only one of such values. This returned sequence value has a different sort arrangement, which we can specify using the proc_option
parameter.
remove_dups(source_data,proc_option)
source_data
: This is the sequence variable from which we want to remove duplicate elements.
proc_option
: This integer value indicates the routine_id
of the duplicate removal option you want. The procedure called by the routine_id
will determine what type of sorting will be performed on the returned sequence.
Note: The
proc_option
parameter is only a name that can be one ofRD_INPLACE
,RD_PRESORTED
, orRD_SORT
. It is evaluated to an integer called aroutine_id
.
proc_option
optionsRD_INPLACE
: This option removes duplicate items with the original order of unique items preserved.
RD_PRESORTED
: With this option, there is an assumption that the items of source_data
are already sorted. If this assumption proves false, the only removed duplicates are the values side-by-side, adjacent duplicate items.
RD_SORT
: This checks for unique values throughout the sequence and returns only the unique values sorted in ascending order.
This function will return a sequence with unique values sorted in an order as indicated.
include std/sequence.e sequence seq = { 3,6,5,6,2,7,5,5,0,3,3,5,6,7} sequence result1 = remove_dups(seq, RD_INPLACE) sequence result2 = remove_dups(seq, RD_SORT) sequence result3 = remove_dups(seq, RD_PRESORTED) sequence result4 = remove_dups(seq, RD_PRESORTED) print(1,result1) puts(1,"\n") print(1,result2) puts(1,"\n") print(1,result3) puts(1,"\n") print(1,result4)
sequence.e
module to access the method.remove_dups()
method.RELATED TAGS
CREATOR
View all Courses