WebQuest Active Member Licensed User Longtime User May 22, 2023 #1 Hello Community. I can't identify via a comparison if there are equal elements in a list. Which is a simple code to identify the duplicate and remove it from the list?. B4A: (ArrayList) [0, 1, 2, 3, 4, 5, 9, 17, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 35, 36, 36, 37, 38, 38, 38, 39, 39, 39, 40, 41, 41, 41, 42, 43, 45, 46, 50, 50, 50, 50]
Hello Community. I can't identify via a comparison if there are equal elements in a list. Which is a simple code to identify the duplicate and remove it from the list?. B4A: (ArrayList) [0, 1, 2, 3, 4, 5, 9, 17, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 35, 36, 36, 37, 38, 38, 38, 39, 39, 39, 40, 41, 41, 41, 42, 43, 45, 46, 50, 50, 50, 50]
johnmie Active Member Licensed User Longtime User Jun 5, 2023 #21 As unsophisticated hobby programmer I simply use killDuplis: List1.sort(true) for i = list1.size-1 to 1 step -1 if list1.get(i) = list1.get(i-1) then list1.remove(i) next Upvote 0
As unsophisticated hobby programmer I simply use killDuplis: List1.sort(true) for i = list1.size-1 to 1 step -1 if list1.get(i) = list1.get(i-1) then list1.remove(i) next
E emexes Expert Licensed User Longtime User Jun 5, 2023 #22 johnmie said: As unsophisticated hobby programmer I simply use killDuplis: List1.sort(true) for i = list1.size-1 to 1 step -1 if list1.get(i) = list1.get(i-1) then list1.remove(i) next Click to expand... Is there any conscious reasoning behind the equality operator being honoured with surrounding spaces, but the subtraction operator not? No problem; just curious. ? Upvote 0
johnmie said: As unsophisticated hobby programmer I simply use killDuplis: List1.sort(true) for i = list1.size-1 to 1 step -1 if list1.get(i) = list1.get(i-1) then list1.remove(i) next Click to expand... Is there any conscious reasoning behind the equality operator being honoured with surrounding spaces, but the subtraction operator not? No problem; just curious. ?
johnmie Active Member Licensed User Longtime User Jun 5, 2023 #23 emexes said: Is there any conscious reasoning behind the equality operator being honoured with surrounding spaces, but the subtraction operator not? No problem; just curious. ? Click to expand... No, just an old habit. But tell me, does this code adequately solve the problem and/or is it slower than working with objects or B4Xsets? Upvote 0
emexes said: Is there any conscious reasoning behind the equality operator being honoured with surrounding spaces, but the subtraction operator not? No problem; just curious. ? Click to expand... No, just an old habit. But tell me, does this code adequately solve the problem and/or is it slower than working with objects or B4Xsets?
E emexes Expert Licensed User Longtime User Jun 5, 2023 #24 johnmie said: But tell me, does this code adequately solve the problem Click to expand... Looked very good to me ? after I wrapped my head around that it wasn't being tripped up by deleted (and now "missing") duplicates. I haven't actually tested it because my previous laptop died last week and I have yet to install B4X onto its replacement. Upvote 0
johnmie said: But tell me, does this code adequately solve the problem Click to expand... Looked very good to me ? after I wrapped my head around that it wasn't being tripped up by deleted (and now "missing") duplicates. I haven't actually tested it because my previous laptop died last week and I have yet to install B4X onto its replacement.