Live data from Hacker News

Bubble sort in pure CSS

dev.to

51–60 of 73 posts

Re: Bubble sort in pure CSS

#51
post #16

Earlier quoted context omitted.

It's called logical addition which is different than arithmetic addition, so it's best to not conflate the two. It's called "addition" because you "add" another propostion, creating a disjunction. And by the rules of logic, as long as the original proposition was true, the truth value is preserved no matter how many propositions you introduce (or "add"). A ⊢ ((A ∨ B) ∨ C) ... ∨ n

> It's called "addition" because you "add" another propostion, creating a disjunction. By that argument, conjunction is also called "addition". Perhaps there's a different reason? The choice of terminology, contrasting "logical addition" with "logical multiplication", obviously indicates that logical addition is supposed to be analogous to addition. What is the analogy?

> By that argument, conjunction is also called "addition". Perhaps there's a different reason?

A chain of (arbitrary) conjunctions is not necessarily implied by the first proposition, so we have the much less interesting:

    A ⊬ ((A ∧ B) ∧ C) ... ∧ n

Re: Bubble sort in pure CSS

#52
post #37

Earlier quoted context omitted.

> It's called "addition" because you "add" another propostion, creating a disjunction. By that argument, conjunction is also called "addition". Perhaps there's a different reason? The choice of terminology, contrasting "logical addition" with "logical multiplication", obviously indicates that logical addition is supposed to be analogous to addition. What is the analogy?

The analogy is deep. But actually the relationship is as follows: P(A u B) = P(A) + P(B) - P(A^B) P(A ^ B) = P(A u B) - P(A) - P(B) And to the guy who said xor is addition — no it’s not: P(A xor B) = P(A) + P(B) - 2 * P(A^B) In Probability, when you have a space of outcomes, doing a Union on two disjoint events (sets of outcomes) the probabilities add. Whereas doing an Intersection on two non-disjoint events those pr…

Interesting, I never saw the arithmetic probability formula for xor.

Though the original topic was truth values, not probabilities. To make it short, conjunctions in probability are multiplicative when they are independent, and disjunctions in probability are additive when they are mutually exclusive.

Re: Bubble sort in pure CSS

#53
post #11

This is scary good. Well done. If your product have any frontend and you have the power to decide ensure at least one of your hires can write CSS at this level.

I think it would be a waste of time if they could because it is both extremely inefficient and has nothing to do with actual frontend skills.

Re: Bubble sort in pure CSS

#54
post #50

Earlier quoted context omitted.

This is the obvious solution I was looking for. Thanks! (and I rightfully feel stupid now)

The formula is slightly wrong though. This is the right one: a or b = a + b - (a * b) The last term is equivalent to a conjunction. Which also makes sense when you think of probability: P(a or b) = P(a) + P(b) - P(a and b)

Awesome, thanks!

For the mod 2 addition, the sign makes no difference I guess, but this cross-link makes the negative sign much more convincing

Re: Bubble sort in pure CSS

#55
post #11

This is scary good. Well done. If your product have any frontend and you have the power to decide ensure at least one of your hires can write CSS at this level.

When you get an idea like "I'm going to X with Y, where Y is not designed to do X", it probably takes several hours or a couple of days to implement it. Are you going to let your hire take that much time? And more importantly, are you going to pay the hire for that time, regardless of whether they succeed in doing it?

Re: Bubble sort in pure CSS

#56
post #16

Earlier quoted context omitted.

It's called logical addition which is different than arithmetic addition, so it's best to not conflate the two. It's called "addition" because you "add" another propostion, creating a disjunction. And by the rules of logic, as long as the original proposition was true, the truth value is preserved no matter how many propositions you introduce (or "add"). A ⊢ ((A ∨ B) ∨ C) ... ∨ n

> It's called "addition" because you "add" another propostion, creating a disjunction. By that argument, conjunction is also called "addition". Perhaps there's a different reason? The choice of terminology, contrasting "logical addition" with "logical multiplication", obviously indicates that logical addition is supposed to be analogous to addition. What is the analogy?

> By that argument, conjunction is also called "addition".

Yeah, I just noticed:

a and b = a + b - (a or b)

Or with probability

P(a and b) = P(a) + P(b) - P(a or b)

Re: Bubble sort in pure CSS

#58
post #5

> (oneIsGreater * origArray[0]) + (twoIsGreater * origArray[1]) There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition. There is not much difference between this and: (oneIsGreater ? origArray[0] : 0) | (twoIsGreater ? origArray[1] : 0) This is often useful to think about when working on bitset or SIMD algorithms.

Posting update since it's too late to edit: I confused multiplication with maximum. It's been too long since I took a course in formal logic. Though for binary values, multiplication works as well.

Re: Bubble sort in pure CSS

#60

Earlier quoted context omitted.

That makes sense, thank you for your great reply. As someone without much mathematical ropes, this might also be related to non-integer algebra and the distinction of "smooth" (edit: or differentiable) and discontinuous functions, no? > The functions maximum and minimum are arithmetic functions as important as addition and subtraction. The only reason for which they have not been counted among the basic arithmetic fu…

As I have mentioned, in the logic systems with 3 or more discrete values of truth (e.g. false, unknown and true, or false, unlikely, unknown, likely and true) and also in the logic systems with a continuous range of truth values (e.g. those based on probabilities), to the base logic functions AND, OR and NOT, correspond the base logic functions minimum, maximum and inversion a.k.a. reflection functions (the last may…

It's interesting that maximum/minimum for disjunction/conjunction doesn't apply for probabilities, except when the probabilities "overlap as much as possible" (when at least one implies the other).

And when the probabilities overlap as little as possible, then the formulas are:

P(a or b) = min(1, P(A)+P(B))

P(a and b) = max(0, P(a)+P(b)-1)

I guess there is some lesson about logic and truth here, but I can't quite see it...

Post reply on HN