Conversation started Oct 8, 2013 at 20:54.
Oct 8, 2013 20:54
@Sparticus monoids are actually not really hard
@enderland It didn't look poisonous...
They just sound funky, but it's got two laws.
Associativity: (a * b) * c = a * (b * c)
Identity: There is one identity i where i * a = a * i = a
Substitute * for your binary operation
so it's got the same rules as matricies
Iduno anything about matricies
user55340
@Sparticus matrices don't have associativity IIRC.
Oct 8, 2013 20:56
is (A * B) * C the same as C * (A * B)
@MichaelT you may be right on that one... Shoot I should know that.
lists under the binary operation of concatenation are an example:
Concatenation operation: ++, Identity element: []

Associative: ([1,2] ++ [3,4]) ++ [5,6] == [1,2] ++ ([3,4] ++ [5,6])
Identity: [] ++ [1,2] = [1,2] ++ [] = [1,2]
user55340
I stand corrected, it does.
user55340
> Matrix multiplication satisfies the rules (AB)C = A(BC) (associativity), and (A+B)C = AC+BC as well as C(A+B) = CA+CB (left and right distributivity), whenever the size of the matrices is such that the various products are defined.
@Sparticus No, that's commutativity when A * B = B * A
yeah alright
matrices can't do that either
Oct 8, 2013 20:58
associativity is where order of operations isn't relevant, commutativity is when order of parameters in a singular operation isn't relevant
monoids don't need to be commutative except with the identity element
user55340
> matrix multiplication is not commutative, in marked contrast to (rational, real, or complex) numbers whose product is independent of the order of the factors.
user55340
user55340
I know matricies aren't commutative guys....
I was asking if monoids were
because it sounds like they are very similar to matricies in terms of allowable operations
(I don't know how that helps me yet)
Nope, monoids don't need to be commutative, just associative and have an identity element
Oct 8, 2013 21:01
so what would the identity monoid look like?
@Sparticus the key is here in a monoid, call your identity mempty and call your binary operation mappend ok, now:

mappend(mempty, A) = mappend(A, mempty) = A
with that you can take your result from your serial number operation, and if it's mempty, you can have a default alternative
mappend(no_serial_returned, default) = default
where no_serial_returned is mempty
you can also do more interesting things then where you compose behaviour

def anAlternativeFunction(functionNeedsSerialNumber, functionIfYouDontHaveSerialNumber)
    return def anonymousFunction(serialNumberReturned)
        if (mappend(serialNumberReturned, mempty) == mempty) // serialNumberReturned is mempty
            return functionIfYouDontHaveSerialNumber()

        return functionNeedsSerialNumber(serialNumberReturned)

then usage:

anAlternativeFunction(doThisWithSerialNumber, shitDoThisIfNoSerialNumber)(tryAndGetASerialNumber());
wow. someone who was requesting programming help and last time we met had no idea responded back to the followup questions I had and gave me a ton of info
I feel... like my job assimilating the real world into the SE "how to ask" is becoming complete
woo hooo reached the first milestone in link-only answers crusade - reviewed all posts under length 200. Thanks to fellow moderators, voters and reviewers, you guys did a fantastic job in last 6 months!
2
Hooray P.SE community, @Sparticus doesn't count. Stupid 25 rep points users...
user55340
@gnat any other fun queries you want me to look into?
Oct 8, 2013 21:14
@JimmyHoffa I'm sure you were rolling in those reviews :P
@MichaelT well, to start with I am not going to simply drop this one. It will only "downgrade" from big project to regular maintenance, to something like cliff questions - we don't have "milestones" at these, do we? :) And, generally, yes I am interested in fun queries
@Sparticus so a structure that might work let's see what we can come up with...

serial numbers can be the set of all natural positive numbers, and identity can be I for now.

The operation could be...
f(x, y) =
  if (x == I) return y
  else if (y == I) return x
  else x || y && (f(x, I))

I think that would work, and technically you could use "I" for your I element in python, being dynamically typed and all
I think, just test it against the laws... the identity should stand up, not sure if the associativity stands...
That last else should say "return" before the expression. I presume here that python will automatically allow for bitwise operations to be executed against any integral like that
shit that's stupid. It should just be else return x. whatever.
not it's not commutative, but that would be associative. 1 * (2 * 3 ) = (1 * 2) * 3 = 1
user55340
@gnat Well, milestones there would be "no cliff questions exist with a rep less than N" - where N is the milestone.
yep that's a functional monoid.
"I" * (2 * 3) = ("I" * 2) * 3 = 2
user55340
There's the flip side of that query - the ones that have accepted answers and thus can't be downvoted over the cliff... they need delete votes.
Oct 8, 2013 21:21
@MichaelT one thing I would be very interested in pretty soon is, would it be possible to run the marginal answers query against older Programmers snapshot - one taken about "mar 12" (date of query creation). I would want to have a retrospective for further use - stats on how many answers remained as is, were edited, deleted, hist-locked... stuff like that
user55340
@gnat Maybe... I'm not sure if the data explorer has older snapshots online... and I'm not sure I have access to a compatible database to run locally.
@MichaelT that's hard to control. Close some old question and you get a candidate for cliff with unknown parameters
@Sparticus just make your failure to find a serial number return "NoSerialFound" and implement that mappend function above which looks for "NoSerialFound" instead of I and make it else return x instead of my stupid code and tada
 
Conversation ended Oct 8, 2013 at 21:23.