Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Math Terminology: Can you tell me?

Math Terminology: Can you tell me?

Scheduled Pinned Locked Moved The Lounge
csharpalgorithmshelpquestion
18 Posts 10 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P PIEBALDconsult

    Are duplicates possible? (Not that it really matters.)

    R Offline
    R Offline
    raddevus
    wrote on last edited by
    #7

    Thanks for your question. Duplicates in orig and new are possible. Duplicates in final set are not allowed.

    P 1 Reply Last reply
    0
    • R raddevus

      Thanks for your question. Duplicates in orig and new are possible. Duplicates in final set are not allowed.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #8

      Yeah, in C# I'd do that with HashSets, slick as snot. HashSet<T>.ExceptWith(IEnumerable<T>) Method (System.Collections.Generic) | Microsoft Docs[^]

      1 Reply Last reply
      0
      • R raddevus

        Background I'm attempting to solve a problem in the most efficient way possible. Attempting to solve the problem put me on the path to attempting to explain the problem. That put me on the path of wondering if there is a term for this. Problem Definition I have two lists of strings. * origItems * newItems I want to find all the strings in newItems that are not contained in origItems. I want to make a new list that contains only those new items. The C# code to solve the problem looks like the following:

        List origItems = new List();
        origItems.Add("abc");
        origItems.Add("def");
        origItems.Add("ghi");

        List newItems = new List();
        newItems.Add("abc");
        newItems.Add("def");
        newItems.Add("super");
        newItems.Add("extra");
        
        List itemsOnlyInNew = newItems.Except(origItems).ToList();
        foreach (String s in itemsOnlyInNew){
        	Console.WriteLine(s);
        }
        

        The output is : super extra Is there a mathematical term that covers this (searching one list based upon another list of items)? (I'm thinking like the term permutation but I don't believe this is a permutation.) Please Feel Free To Make Up A Term If there isn't already a term (in English), please make one up. If there is a term in another language please share that and we'll incorporate it. Just thought this was interesting. Thanks much.

        M Offline
        M Offline
        megaadam
        wrote on last edited by
        #9

        I agree with the previous posters: Set Theory In C++ there is the container std::set something similar exists in Python so I assume C# also has something like it. In C++ it looks like this: set_difference - C++ Reference[^]

        "If we don't change direction, we'll end up where we're going"

        1 Reply Last reply
        0
        • N NeverJustHere

          Isn't it set theory: newItems - origItems? Think of the two sets as a Venn Diagram, intersection, union, etc.

          0 Offline
          0 Offline
          0x01AA
          wrote on last edited by
          #10

          I just missed that you answered already with set theory. Was not my intention to plagiarize ;)

          1 Reply Last reply
          0
          • R raddevus

            After posting. I got up. Walked out to make coffee and was talking to the wife unit when that hit me. Blush | :O Thank you for your informative and kind answer. :thumbsup: I think I must've been thinking of the specific instance and related code so much I confused my simple brain. I'm kinda dumb sometimes. :rolleyes:

            0 Offline
            0 Offline
            0x01AA
            wrote on last edited by
            #11

            Don't worry, happens to me nearly everyday and sometimes (usually?) more than one time per day :-O

            R 1 Reply Last reply
            0
            • 0 0x01AA

              Don't worry, happens to me nearly everyday and sometimes (usually?) more than one time per day :-O

              R Offline
              R Offline
              raddevus
              wrote on last edited by
              #12

              Thank you :thumbsup: I'm crawling under my desk for while.

              0 1 Reply Last reply
              0
              • R raddevus

                Thank you :thumbsup: I'm crawling under my desk for while.

                0 Offline
                0 Offline
                0x01AA
                wrote on last edited by
                #13

                No need ;) Or then I also have to do it. A customer send me the information the angle is 390 deegree. I was that much confused and answered this can't be possible. On the other hand I have no problem when somebody tells me the angle is 2.5 π rad whatelse :laugh:

                1 Reply Last reply
                0
                • R raddevus

                  Background I'm attempting to solve a problem in the most efficient way possible. Attempting to solve the problem put me on the path to attempting to explain the problem. That put me on the path of wondering if there is a term for this. Problem Definition I have two lists of strings. * origItems * newItems I want to find all the strings in newItems that are not contained in origItems. I want to make a new list that contains only those new items. The C# code to solve the problem looks like the following:

                  List origItems = new List();
                  origItems.Add("abc");
                  origItems.Add("def");
                  origItems.Add("ghi");

                  List newItems = new List();
                  newItems.Add("abc");
                  newItems.Add("def");
                  newItems.Add("super");
                  newItems.Add("extra");
                  
                  List itemsOnlyInNew = newItems.Except(origItems).ToList();
                  foreach (String s in itemsOnlyInNew){
                  	Console.WriteLine(s);
                  }
                  

                  The output is : super extra Is there a mathematical term that covers this (searching one list based upon another list of items)? (I'm thinking like the term permutation but I don't believe this is a permutation.) Please Feel Free To Make Up A Term If there isn't already a term (in English), please make one up. If there is a term in another language please share that and we'll incorporate it. Just thought this was interesting. Thanks much.

                  O Offline
                  O Offline
                  obermd
                  wrote on last edited by
                  #14

                  In Set Theory, the opposite of "Intersection" is "Difference". You're describing a Difference operation.

                  E 1 Reply Last reply
                  0
                  • O obermd

                    In Set Theory, the opposite of "Intersection" is "Difference". You're describing a Difference operation.

                    E Offline
                    E Offline
                    englebart
                    wrote on last edited by
                    #15

                    Be careful on order if you use a library. A.diff(B) != B.diff(A) I have seen Difference used for this operation. It looks like Complement could be another term. There is also Symmetric Difference which contains outliers from both sets.

                    1 Reply Last reply
                    0
                    • R raddevus

                      Background I'm attempting to solve a problem in the most efficient way possible. Attempting to solve the problem put me on the path to attempting to explain the problem. That put me on the path of wondering if there is a term for this. Problem Definition I have two lists of strings. * origItems * newItems I want to find all the strings in newItems that are not contained in origItems. I want to make a new list that contains only those new items. The C# code to solve the problem looks like the following:

                      List origItems = new List();
                      origItems.Add("abc");
                      origItems.Add("def");
                      origItems.Add("ghi");

                      List newItems = new List();
                      newItems.Add("abc");
                      newItems.Add("def");
                      newItems.Add("super");
                      newItems.Add("extra");
                      
                      List itemsOnlyInNew = newItems.Except(origItems).ToList();
                      foreach (String s in itemsOnlyInNew){
                      	Console.WriteLine(s);
                      }
                      

                      The output is : super extra Is there a mathematical term that covers this (searching one list based upon another list of items)? (I'm thinking like the term permutation but I don't believe this is a permutation.) Please Feel Free To Make Up A Term If there isn't already a term (in English), please make one up. If there is a term in another language please share that and we'll incorporate it. Just thought this was interesting. Thanks much.

                      L Offline
                      L Offline
                      Leo56
                      wrote on last edited by
                      #16

                      OK, not a Maths term per se, but when anyone invokes the 'M' word in my hearing I always think "Freudenschade"...... :-D

                      B 1 Reply Last reply
                      0
                      • L Leo56

                        OK, not a Maths term per se, but when anyone invokes the 'M' word in my hearing I always think "Freudenschade"...... :-D

                        B Offline
                        B Offline
                        Bruce Patin
                        wrote on last edited by
                        #17

                        You mean SchadenFreude?

                        1 Reply Last reply
                        0
                        • R raddevus

                          Background I'm attempting to solve a problem in the most efficient way possible. Attempting to solve the problem put me on the path to attempting to explain the problem. That put me on the path of wondering if there is a term for this. Problem Definition I have two lists of strings. * origItems * newItems I want to find all the strings in newItems that are not contained in origItems. I want to make a new list that contains only those new items. The C# code to solve the problem looks like the following:

                          List origItems = new List();
                          origItems.Add("abc");
                          origItems.Add("def");
                          origItems.Add("ghi");

                          List newItems = new List();
                          newItems.Add("abc");
                          newItems.Add("def");
                          newItems.Add("super");
                          newItems.Add("extra");
                          
                          List itemsOnlyInNew = newItems.Except(origItems).ToList();
                          foreach (String s in itemsOnlyInNew){
                          	Console.WriteLine(s);
                          }
                          

                          The output is : super extra Is there a mathematical term that covers this (searching one list based upon another list of items)? (I'm thinking like the term permutation but I don't believe this is a permutation.) Please Feel Free To Make Up A Term If there isn't already a term (in English), please make one up. If there is a term in another language please share that and we'll incorporate it. Just thought this was interesting. Thanks much.

                          J Offline
                          J Offline
                          John Godin
                          wrote on last edited by
                          #18

                          In case it might be useful to you. I have ubuntu Linux running on my Win 10 laptop (WSL) and it has this handy program called comm. I use it when I need to do a task like you describe. HTH Usage: comm [OPTION]... FILE1 FILE2 Compare sorted files FILE1 and FILE2 line by line. When FILE1 or FILE2 (not both) is -, read standard input. With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups