• 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?

  • 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.)

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

  • 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)


    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."

Log in to reply