removeDuplicateElements

Post your questions and help other users.

Moderator: Martin

simon_magus101
Posts: 38
Joined: 06 Sep 2017 06:59

removeDuplicateElements

Post by simon_magus101 » 08 Sep 2017 03:42

removeDuplicateElements() function does not give me the intended result. It does not seem to remove duplicates. It will only remove one elements if there are more than 3 of the same. Can somebody please confirm this? Here is what I did

global_x1=removeDuplicateElements(global_x1);

I have also tried
removeDuplicateElements(global_x1);

I still get duplicates in the list. No error message when executing the flow.
I am on the Automagic 1.33.0 and android 4.4

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: removeDuplicateElements

Post by Bluscre » 08 Sep 2017 04:51

simon_magus101 wrote:global_x1=removeDuplicateElements(global_x1);
What's the content of your global_x1 variable?
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

simon_magus101
Posts: 38
Joined: 06 Sep 2017 06:59

Re: removeDuplicateElements

Post by simon_magus101 » 08 Sep 2017 04:58

global_x1 is a list of Cell ID. Each element is a number of 7 digits length.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: removeDuplicateElements

Post by Desmanto » 08 Sep 2017 05:10

I get the proper result, all duplicate element will be removed, either 2 or 3, will become only 1. That 2 elements those didn't removed must be checked if they are the same. If global_x1 = [x, tes, tes, abc], means element 2 and 3 seems duplicate. Try
a = global_x1[1] == global_x1[2]
use debug dialog to check a.

a must be false if they are not the same. You can try to encode them to see if any "invisible whitespace" or special character. Try
e = encodeURL(global_x1[1])
f = encodeURL(global_x1[2])

Check if e and f now shows something that is not supposed to be there.

I have similiar problem with you. When I parse my flowception, I also curious why the element not removed. Turns out "\n" (newline), when stored inside list, will become empty string, but not null. That element doesn't match null or empty, but match with '' (two single quote). Confirmed it via debug dialog. Debug dialog really helps a lot. Can't imagine scripting without it.

You don't need to assign the value back when using remove series. Just the remove function is enough, no need = anymore.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: removeDuplicateElements

Post by Bluscre » 08 Sep 2017 05:11

simon_magus101 wrote:global_x1 is a list of Cell ID. Each element is a number of 7 digits length.
Add a "Debug Dialog" condition to the end, wait for it to pop up then tap on "global_x1" then tap on copy and obfuscate personal stuff then post it for us to review
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

simon_magus101
Posts: 38
Joined: 06 Sep 2017 06:59

Re: removeDuplicateElements

Post by simon_magus101 » 08 Sep 2017 05:51

I have tried the encodeURL for the two elements, display on screen notification, and they are duplicate.
Let me give more details. I have twelve unique numbers and one duplicate.
//script begin
global_x2=newList(7350474, 7350475, 1608847, 1618847, 1618846, 1608846, 7350473, 1628846); //eight numbers
global_x3=newList(1124582, 7344998, 7345098, 1134582); //four numbers
global_x4=newList(1608847); //notice this number is a duplicate in global_x2[2]
global_x1=newList();
//combining all elements in global_x1
global_x1=addAllElements(global_x1, global_x2);
global_x1=addAllElements(global_x1, global_x3);
global_x1=addAllElements(global_x1, global_x4);
removeDuplicateElements(global_x1);
//script end

Now when I view global variables I can see 1608847 occur twice in global_x1.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: removeDuplicateElements

Post by Desmanto » 08 Sep 2017 05:59

I've tried your script without modification.
The result of global_x1 is
[7350474, 7350475, 1608847, 1618847, 1618846, 1608846, 7350473, 1628846, 1124582, 7344998, 7345098, 1134582]

12 elements. If I comment out the remove(), it will have 13 elements, 1608847 at the end.

I am using Automagic 1.33.0 on LP 5.1, root + Xposed.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

simon_magus101
Posts: 38
Joined: 06 Sep 2017 06:59

Re: removeDuplicateElements

Post by simon_magus101 » 08 Sep 2017 06:52

Thanks for trying out Desmanto. On my phone global_x1 end up with 13 elements. 1608847 being the last element. I can see two of 1608847.

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: removeDuplicateElements

Post by Bluscre » 08 Sep 2017 08:07

simon_magus101 wrote:Thanks for trying out Desmanto. On my phone global_x1 end up with 13 elements. 1608847 being the last element. I can see two of 1608847.
Can you share your full flow so we can try to help you ? Make sure to remove personal info before uploading
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

simon_magus101
Posts: 38
Joined: 06 Sep 2017 06:59

Re: removeDuplicateElements

Post by simon_magus101 » 08 Sep 2017 10:44

Bluscre wrote:
Can you share your full flow so we can try to help you ? Make sure to remove personal info before uploading
I am new to this forum. I just clicked Publish Flows at the bottom, and selected some flows. I hope you receive them. The objective is to collect Cell Id from three different areas, one area at a time, and combine them into one list, without duplicate. Cell collector stopper flow is where I combined them.
http://automagic4android.com/flow.php?i ... a5cfad9c41
Last edited by simon_magus101 on 08 Sep 2017 10:56, edited 2 times in total.

Post Reply