Wdym by casting. Doesn't that require knowing what to cast to?
And if you're matching, how's that any different from a Rust-style enum? It's just less powerful since you can't have multiple things with the same type (e.g., an int used for a time vs. an int used for a full datetime)
With a Rust enum you can do things way more complicated than an AST, where it would be very unclear what types map to what possibilities, which would be unsuitable for unions
@RydwolfPrograms what i mean is the X enum is literally (ive seen the bytecode myself) compiled as class X { static X Y = new X(1); static X Z = new X(2); final int number; private X(int number) { this.number = number }}
@RydwolfPrograms they... dont? thats what i mean by constant
Although I do see why Rust doesn't do assoc data; it would make more sense to put that in like, a match on the enum rather than in the enum itself a lot of the time
Doing both at once might be kind of mutually exclusive for whether or not they're reasonable
Yeah but Rust-style is way more capable than Java-style, right? And no reason you can't just have some sort of method that allows you to conveniently use a dict for associated data
How spherical is my ellipsoid? (Willmore energy)
code-golfmathgeometry
Define the (unnormalised) Willmore energy of a surface as the integral of squared mean curvature over it:
$$W=\int_SH^2\,dA$$
For surfaces topologically equivalent to a sphere \$W\ge4\pi\$, and \$W=4\pi\$ iff it is actually a ...
Coming up with a good name for OTTNB is so hard because it needs to communicate more off-topic than a Nineteenth Byte/Hole, but still needs to communicate "golfing/CGCC"
@emanresuA The wording here is important: studying history only prepares you for forty years of teaching it. Just learning some history isn't a problem if you don't major in it. And even if you do major in history, you don't have to teach history, you just won't be prepared for any other job. :P </lit-se>
(There has been more than one occasion at my job when I've found it appropriate to sing under my breath, "CS will make each day a quest to find a missing close-paren"...)
@DLosc when i see a message with only a closing tag i imagine that the corresponding opening tag was somewhere far back and everything up to now has been inside the lit-se/rant/whatever element
Write a program that, for any $n$, generates a triangle made of hexagons as shown, $2^n$ to a side. The colors are to be determined as follows.
We may give the triangle barycentric coordinates so that every hexagon is described by a triple $(x,y,z)$ with $x+y+z=2^n-1$. (The three corners will be ...
@AviFS howdy and thanks for the welcome -- you'll have to forgive my delay, i don't check SE often anymore.
I had a perhaps simpler Haskell question than my other one -- probably doesn't warrant a tips thread. Is there any good way to deal with ambiguous type variables when defining a short form of a function?
[Here's an example](https://tio.run/##y0gszk7Nyfn/PzcxM8@2QMFQy65AIdpQxyiWq0DBykohOCO/XCFRwdYOSOjaKXj6K2hochXYFhRl5pX8/w8A) where I want to shorten `print` to `p`.