Might I suggest a different animation. The current one swaps two elements (bars) by vertically shrinking the taller bar and growing the shorter one. Instead, the bars should stay the same height but move horizontally. I would rather see values move than slots in the array morph to the new value they should hold. The current animation feels like you are pumping water from one tank to another.
Bubble sort in pure CSS
31–40 of 73 posts
Re: Bubble sort in pure CSS
#32Earlier quoted context omitted.
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
#33Earlier 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
The logical "and" and logical "or" functions are precisely particular cases of the minimum and maximum functions.
The so-called "exclusive or" function is simultaneously a particular case of addition and of subtraction, i.e. addition modulo 2 and subtraction modulo 2 are the same function. Therefore applying the 4 functions minimum, maximum, addition and subtraction to 1-bit numbers produces only 3 functions, AND, OR and XOR.
It makes no sense to search other functions for expressing logical "and" and logical "or" except for minimum and maximum, because this is what they are. The search could only find alternative more complicated ways to express minimum and maximum.
The minimum and maximum functions also work in logic systems with more than 2 values of truth. Also in hardware, analog circuits for minimum and maximum are one of the 2 ways of implementing the logical "and" and "or" functions, the other way being with series and parallel connections.
The main mistake of George Boole was his unsuccessful attempt to find an equivalence between logical "and" and "or" and integer multiplication and addition, because he was not habituated to use minimum and maximum, so he did not see the correct relationships.
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 functions is because when computed by a human they required much less effort than even addition, so there was no need for a long training of how to do computations with them, like for the more complex arithmetic functions.
Most modern instruction-set architectures now include maximum and minimum instructions, together with the addition and subtraction instructions.
Re: Bubble sort in pure CSS
#34Earlier quoted context omitted.
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
The abs function works because it is equal to the maximum of x and -x. The logical "and" and logical "or" functions are precisely particular cases of the minimum and maximum functions. The so-called "exclusive or" function is simultaneously a particular case of addition and of subtraction, i.e. addition modulo 2 and subtraction modulo 2 are the same function. Therefore applying the 4 functions minimum, maximum, addit…
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 functions is because when computed by a human they required much less effort than even addition
Re: Bubble sort in pure CSS
#35Earlier quoted context omitted.
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.
Most textbooks define a set of elementary functions which does not include maximum and minimum only because they use "elementary" as an abbreviation for "elementary and differentiable", and they do not bother to explain this to the students.
Re: Bubble sort in pure CSS
#36Earlier 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 :)
Re: Bubble sort in pure CSS
#37Earlier 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?
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 probabilities multiply. If two events have no outcomes in common, for instance, the probability of them both occurring is zero.
When you “condition” probability on an event X happening, you restrict the space of all outcomes to that set X, and intersect every event with it.
When you condiition B[n] = A[n] given that (A[n-1] AND … A[1]) having already happened, you have a sales funnel and each step is independent of the previous, so the probabilities multiply.
It is also called a Markov Chain if you have a discrete set of possibilities at each step so you can form a matrix.
Re: Bubble sort in pure CSS
#38This 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.
Re: Bubble sort in pure CSS
#39Earlier 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 :)
a + b + a * b
Re: Bubble sort in pure CSS
#40Earlier quoted context omitted.
The abs function works because it is equal to the maximum of x and -x. The logical "and" and logical "or" functions are precisely particular cases of the minimum and maximum functions. The so-called "exclusive or" function is simultaneously a particular case of addition and of subtraction, i.e. addition modulo 2 and subtraction modulo 2 are the same function. Therefore applying the 4 functions minimum, maximum, addit…
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…
A set with minimum and maximum operations has a special algebraic structure named distributive lattice, which is a structure as useful and frequently encountered as structures like the algebraic groups and rings that characterize addition-like and multiplication-like operations.