Reputation
18,090
Top tag
Next privilege 20,000 Rep.
Access 'trusted user' tools
Badges
1 47 73
Newest
 Nice Answer
Impact
~309k people reached

Jul
20
comment rand() gives same numbers again for a small range
@Dorus You still need to generate and store the entire list though. In most cases where shuffling the entire list is prohibitive, that's already a dealbreaker.
Jul
20
awarded  Nice Answer
Jul
20
revised rand() gives same numbers again for a small range
added 12 characters in body
Jul
20
answered rand() gives same numbers again for a small range
Jul
16
answered Is async keyword an ultimate replacement for asyncio module?
Jul
13
comment Is there any programming language(s) which has mathematical number types?
@SimonB You seem to confuse cardinality with well-ordering or something related to it. A countable set has a bijection with the naturals, but there is no requirement that this mapping preserves order (or that there even is such a thing as an "order"). The rationals are countable, for example, even though there is yet another rational between any two rationals.
Jul
12
comment When writing a math library, will operator overloading maintain OOP?
@Ixrec That is a different operation though. Your code does ((A + B) * C) + E, OP's method example does A + (B * (C + E)).
Jul
12
comment Banning zero-argument functions — what problems could it cause in a hypothetical language?
I see. But with this function call syntax, a better option is to go all the way with currying. Then no separate function is necessary and it becomes more consistent that binding the only remaining parameter calls the function.
Jul
12
comment Is there any programming language(s) which has mathematical number types?
@nawfal Just the names is a strange requirement. In particular for your favorite approximation of reals, names like "float" or "double" or "decimal" are good, I'd argue, even for beginners, because they make very clear that there are not the real numbers (and unlike integers for example, the differences are easy to hit even without overflow). As for uncountability: In short, there is no way to list all reals - any list, even infinite, must necessarily miss most of them. More technically, there is no one-to-one mapping from the natural numbers to the reals. See Cantor's diagonal argument.
Jul
12
comment Banning zero-argument functions — what problems could it cause in a hypothetical language?
I don't quite follow the part about parameter binding. If f is a function T -> U, then f x doesn't just bind a value to the first parameter, it calls the function, because now all arguments are supplied. This is what several functional languages do. In fact, it is the only reasonable course of action that I can imagine with that function call syntax.
Jul
12
comment Banning zero-argument functions — what problems could it cause in a hypothetical language?
Isn't this exactly what Haskell does? Well, except that variable = expression defines an unchangeable binding rather than assigning to a variable.
Jul
11
answered Is there any programming language(s) which has mathematical number types?
Jul
11
revised Why does Python need both a compiler and an interpreter?
added 25 characters in body
Jul
11
answered Why does Python need both a compiler and an interpreter?
Jun
30
revised Does it make sense to choose UTF-32, based on concern that some basic rule will be broken for UTF-8?
added 71 characters in body
Jun
27
comment What problem do algebraic data types solve?
@usr Finding the catch-all clause is not what the compiler does (and in any case is a simple syntactic transformation as you describe). However, the compiler instead has to check if clause1 || clause2 || ... is a tautology, which is indeed equivalent to testing the satisfiability of !clause1 && !clause! && ... - but I'm still skeptical because this is a reduction from exhaustiveness to SAT, not the other way around (i.e., if we can solve SAT we can solve exhaustiveness, but no mention of the other way around).
Jun
27
comment What problem do algebraic data types solve?
@usr No language I'm aware of attempts a perfect solution, either the compiler understands that it's exhaustive or you're forced to add a catch-all case where you crash and burn. I don't know of a relation to SAT though, do you have a link to a reduction? Regardless, for actual code written in real programs, exhaustiveness checking is a drop in the bucket.
Jun
24
awarded  Good Answer
Jun
22
awarded  Good Answer
Jun
22
comment What problem do algebraic data types solve?
@Ian Most functional languages are statically typed and check exhaustiveness of pattern matching. However, if there is a "catch all" pattern, the compiler is happy even if the function would have to deal with the new case to do its job. In addition, you have to recompile all dependent code, you can't compile just one library and re-link it into an already-built application.