I am trying to find a duplicate between the sublists of a list , if I have this list
let listA [[-9 2] [-9 1] [-9 0][-9 -1][-9 -2][-9 -3][-9 -4][-8 0][-9 0]]
and it is a restriction that this list can have only one sublist that can be repeated which in these case is [-9 0] I would like to save these two elements in 2 variables for example :
let element-x item 0 ?
let element-y item 1 ?
but i don't actually know how to compare two sublist of a list with each other if they have the same elements.
After taking these variables(element-x element-y), i have to remove every sublist in listA that contain one of these variables -9 or 0 and save the remaining cordinates in a new list(list-cordinates)
I have already done this by taking this variables(of the duplicated sublist) as constants (for testing purposes) in these code below :
globals [
list-cordinates
element-x
element-y
]
set element-x -9
set element-y 0
foreach listA [
if item 0 ? != element-x AND item 1 ? != element-y[
let x item 0 ?
let y item 1 ?
set list-cordinates lput( list x y ) list-cordinates
]
]
Now I just need these variables not be constants but the 2 items from the duplicated sublist of listA.
This is quick and dirty, but find-dup should return the first duplicated item (in this case a sublist) in the list.
The rest of your code should take it from there.