User Tag List

Results 1 to 8 of 8

Thread: remove duplicates in list objects

  1. #1
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Oct 2006
    Location
    In a Dark room with only a lamp
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    remove duplicates in list objects

    Hi all, I am trying to achieve the following but can't write it down in any form of sense!!

    List1

    hello
    open
    close
    toy
    dog
    cat

    List2
    Hello-here
    Hello-here
    open-door
    close-window
    potato-farm
    close-window
    toy-shop
    dog-pet
    cat-kitten
    dog-pet
    dog-pet
    toy-shop
    fox-chicken
    sweet-sour


    Remove duplicates from List2:

    Hello-here
    open-door
    close-window
    potato-farm
    toy-shop
    dog-pet
    cat-kitten
    fox-chicken
    sweet-sour

    Compare the first part of the list2 items with the contents of list1 and remove any matches to leave the ones that don't match:

    potato-farm
    fox-chicken
    sweet-sour

    Does any of that make sense??? I am using the String Tokenizer to read the first part of list 2 but i cannot make it work. I am now unable to read my code properly so i have nothing to base anything on!!

    Been staring at it for too long i think! :crazy:

  2. #2
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: remove duplicates in list objects

    I can't write you the entire program since that would be make your work a bit moot, but I can certainly draw you up some pseudocode for an algorithm to do it.


    Code:
    operating on input (list list1, list list2)
    define list temp1;
    define list temp2;
    define list temp3;
    define bool checker;
    
    
    //The following code does this
    //Read in each element of the first list one by one
    //For each element, check to see if its in the temporary list
    //Do this by iterating over each element in temp1 and comparing it
    //If it wasn't in that list, add it to the temporary list
    //Once this is finished, temp1 will be the non-redundant elements of list1
    
    for (i = 0; i++; i < size(list1)) do
     checker = false;
     for (j = 0; j++; j < size(temp1)) do
      if (temp1[j] == list1[i]) then
       checker = true;
      end
      if checker == false then
       temp1.addElement(list1[i]);
      end
     end
    end
    
    
    //Now copy/paste the above code for list 2.
    //This does the exact same thing, making temp2 into the 
    //Non-redundant elements of list 2
    
    for (i = 0; i++; i < size(list2)) do
     checker = false;
     for (j = 0; j++; j < size(temp2)) do
      if (temp2[j] == list2[i]) then
       checker = true;
      end
      if checker == false then
       temp2.addElement(list2[i]);
      end
     end
    end
    
    
    //Now this is the tricky part. Compare the list temp1 to temp2
    //This time, read only the leftmost digits of temp2, based on
    //the # of chars in string 1, to check for matches
    //without parsing for the "-" symbol this could lead to 
    //false positives if you say had "ass-kick" and "assassin-ninja"
    //And list1 contained "ass". In which case you'd want to use a
    //String tokenizer to read the string up to the "-" object;
    //you'd have to figure out how to do that yourself
    //The final product is "temp3"
    
    for (i = 0; i++; i < size(temp2)) do
     checker = false;
     for (j = 0; j++; j < size(temp1)) do
      if (temp1[j] == right$(temp2[i],size(temp1[j])) then
       checker = true;
      end
      if checker == false then
       temp3.addElement(temp2[i]);
      end
     end
    end


    This is all pseudocode, it won't run in any language.
    Its just a general algorithm that will do exactly what you wanted- and it can easily be done in MMF2, using just

    *List Objects
    *Fast Loops
    *The "Compare 2 general values" condition


    Translating between the pseudocode and MMF2 is where all the work is >.>

  3. #3
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Oct 2006
    Location
    In a Dark room with only a lamp
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: remove duplicates in list objects

    cheers. i'll give it a go!

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: remove duplicates in list objects

    the key part is using the left$() function in the expression editor

    left$("string",x) gives the X leftmost characters in the string as a new string. So left$("Hello World",5) = "Hello"


    But careful in that that would make your code behave in a way you might not want- a word in list1 would delete the entry from list2 even if it wasn't entirely matching, for example "a" would delete "antidisestablishmentarianism-cool" because it reads only the leftmost "a".

    Theres a way with the string tokenizer to read the # of characters up to the "-", if thats your token. good luck

  5. #5
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Oct 2006
    Location
    In a Dark room with only a lamp
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: remove duplicates in list objects

    I might just get rid of the tokenizer as all the items in list 1 are 13 characters long anyways.

  6. #6
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: remove duplicates in list objects

    Or you could compare left$(string from list 2, len(string from list 1 + "-")) equals string from list 1 + "-".

    No tokeniser needed, just add "-" before you compare

  7. #7
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: remove duplicates in list objects

    Durr -.-
    Why didn't I think of that? :P
    Anyway, including what Dynasoft said, see how this program compares to what you created. I lied when I said I couldn't make this for the whole 'learning experience thingy' :P

    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=213013#Post2130 13

  8. #8
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Oct 2006
    Location
    In a Dark room with only a lamp
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: remove duplicates in list objects

    It's pretty slick i have to say. I think i may have broken it though as some of the values aren't deleted!! :crazy:

    I'm gonna look at it again though!!!

    Cheers

    EDIT - Fixed it!!!!

    Thanks

Similar Threads

  1. Add/Remove objects from Groups
    By Kentronisk in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 12th November 2011, 09:05 AM
  2. Remove first No# objects when count reaches limit
    By ionside in forum Multimedia Fusion 2 - Technical Support
    Replies: 15
    Last Post: 9th August 2009, 12:15 AM
  3. List Object - not remove empty lines?
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd September 2008, 04:32 PM
  4. Delete List Duplicates
    By dingdong in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 25th December 2007, 05:10 PM
  5. Install Creator #29 Add/Remove List Size Error
    By PatrickL in forum Install Creator and Patch Maker
    Replies: 7
    Last Post: 5th December 2007, 10:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •