Live data from Hacker News

Bubble sort in pure CSS

dev.to

21–30 of 73 posts

Re: Bubble sort in pure CSS

#21
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.

This is a fun proof of concept, but it isn't what CSS is used for. There's no conceivable reason you'd do this in practice.

Those you know it well can abuse it in a fun way. Probably not useful in practice. Nevertheless this proves talent of the one who wrote it.

Re: Bubble sort in pure CSS

#22
post #2

> Editor’s Note: This article ends on a cliffhanger. The next part goes out in a week I stopped reading there. Let us know when the second part is out. Why write half an article?

[deleted]

Re: Bubble sort in pure CSS

#23
post #2

> Editor’s Note: This article ends on a cliffhanger. The next part goes out in a week I stopped reading there. Let us know when the second part is out. Why write half an article?

Why release half a product? We should only release when 100% of the features are completed.

Re: Bubble sort in pure CSS

#24
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?

I don't know if this relates to formal logic, but in C a true value is defined as not zero, so all nonzero values are treated as the same value. So the only way to get a false is to OR (or add) two zeroes, making the two operations equivalent as far as boolean logic goes.

Actually, you can add 1 and -1 to get 0, which breaks the model... Hmm... Guess it only works on natural numbers / unsigned.

Re: Bubble sort in pure CSS

#26
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.

> There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition. Really? The connection between AND and multiplication is obvious, but disjunction doesn't behave like addition. (For one thing, just like AND, it destroys information, which multiplication does do and addition doesn't.) Addition would usually be XOR. In fact, AND and XOR are what you get when you ap…

Is there a way to express OR (not XOR) using integer arithmetic without case distinction or special functions in the natural numbers mod 2?

Meaning, using only elementary arithmetic and modulo?

Seems like there should be either an obvious answer or an interesting one :)

Re: Bubble sort in pure CSS

#27

Earlier quoted context omitted.

> There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition. Really? The connection between AND and multiplication is obvious, but disjunction doesn't behave like addition. (For one thing, just like AND, it destroys information, which multiplication does do and addition doesn't.) Addition would usually be XOR. In fact, AND and XOR are what you get when you ap…

Is there a way to express OR (not XOR) using integer arithmetic without case distinction or special functions in the natural numbers mod 2? Meaning, using only elementary arithmetic and modulo? Seems like there should be either an obvious answer or an interesting one :)

The maximum function.

Re: Bubble sort in pure CSS

#28
post #27

Earlier quoted context omitted.

Is there a way to express OR (not XOR) using integer arithmetic without case distinction or special functions in the natural numbers mod 2? Meaning, using only elementary arithmetic and modulo? Seems like there should be either an obvious answer or an interesting one :)

The maximum function.

Yeah that makes sense of course. Should have specified "special function", was aiming at "algebraic" or "polynomial" I guess.

Then the answer seems to be no, right?

Edit: The abs() function seems to be enough, awesome:

https://math.stackexchange.com/a/1641271

Re: Bubble sort in pure CSS

#29
post #27

Earlier quoted context omitted.

Is there a way to express OR (not XOR) using integer arithmetic without case distinction or special functions in the natural numbers mod 2? Meaning, using only elementary arithmetic and modulo? Seems like there should be either an obvious answer or an interesting one :)

The maximum function.

The maximum function isn't elementary arithmetic or modulo. You can define it as a limit, but people are unlikely to be convinced that that's a simple, elementary function.

Re: Bubble sort in pure CSS

#30
post #27

Earlier quoted context omitted.

The maximum function.

Yeah that makes sense of course. Should have specified "special function", was aiming at "algebraic" or "polynomial" I guess. Then the answer seems to be no, right? Edit: The abs() function seems to be enough, awesome: https://math.stackexchange.com/a/1641271

[deleted]
Post reply on HN