Removing duplicate in list of pairs

hello
i have a list of pairs for example {(1,2),(2,1),(4,5),(5,4)}, what i'm trying to do to remove the duplicate by deleting the pairs (2,1),(5,4) so the list will be {(1,2),(4,5)} , i have this code

v<- lapply(v, function(s) {s[[NULL]] <- NULL; s})
v<-lapply(v,function(y){x1 <- unlist(y)
l1 <-unique(lapply(split(as.vector(x1),as.vector(gl(length(x1), 2,length(x1)))), sort))
do.call(set,lapply(l1, function(y) pair(y[1], y[2])))

now this code working very will but sometimes it gave me this error

"Error in split.default(as.vector(x1), as.vector(gl(length(x1), 2, length(x1)))) : first argument must be a vector for example if i have this list of pairs"
i'm using Rstudio with sets and igraph packages
thanks

I am unable to run the code you have supplied. Could you check and make sure, that the code contain everything needed to illustrate your challenge? :slightly_smiling_face:

See here for more on reproducible examples

hello Leon , sorry for that first we should create v

v<-vector(mode = "list",length = 2)
v[[1]]<-set(pair(1,2))
v[[1]]<-append(x[[1]],set(pair(2,1)))
v[[2]]<-set(pair(4,5))
v[[2]]<-append(x[[2]],set(pair(5,4)))

after that you can run the code
thank you :slight_smile:

Btw. is this question a continuation of this question?

If so, please continue in that discussion - It is easier to follow a discussion, if it is confined to one thread :slightly_smiling_face: