MU Soapbox

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Muxify
    • Mustard

    Setunion

    MU Questions & Requests
    4
    4
    2317
    Loading More Posts
    • 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.
    • 3543thrh67
      3543thrh67 last edited by

      Okay, I am trying to advance my coding skills (I hassle Theno a lot) but I don't really understand how setunion() works. There's a few others I don't understand but, atm, this is the one I am focusing on trying to understand. I was trying 'just doing' but it does not seem to be clear to me still. Anyone able to help a gal out?

      1 Reply Last reply Reply Quote 0
      • Thenomain
        Thenomain last edited by

        Do you know about Venn Diagrams?

        Union: add the two circles together.
        Intersect: just the part where the circles overlap.
        Difference: the first circle minus the second circle.

        Each circle is called a 'set', as in a set of numbers, a set of words, a set of shapes.

        Union: everything from both sets.
        Intersect: only things that are in both sets
        Difference: things in the first set that are not in the second set (set1 - intersect)

        On Mu*, the set functions will also sort and return one, and only one, of each item, you may start with 'a a a', but you will end up with 'a'. (Aka, a distinct set.)

        “If you wish to make an apple pie from scratch, you must first invent the universe.”
        ― Carl Sagan, Cosmos

        1 Reply Last reply Reply Quote 1
        • Glitch
          Glitch last edited by

          All sets are composed of distinct, or uniquely identifiable, objects. The basics.

          1 Reply Last reply Reply Quote 0
          • Chime
            Chime last edited by

            Set operations are useful for combining (or separating) groups of things you are interested (or not interested) in operating upon.

            Consider use-case: What friends of mine are online now? (set-intersection of lwho and your private list of friends)

            tl;dr:

            union of (a b c d) (c e f g) -> (a b c d e f g)
            intersection of (a b c d) (c e f g) -> (c)

            Often you'll see mushcode like setunion(%va,) or similar. What this is doing is saying "perform a simple (lexicographical) sort on the elements of %va, remove any duplicates, and return it."

            It is by will alone I set my mind in motion. It is by the juice of Coffea arabica that thoughts acquire speed, the table acquires stains, the stains become a warning. It is by will alone I set my mind in motion.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post