@lyxal Your setAttribute method doesn't look right
The type parameter Integer shadows the actual class java.lang.Integer, you don't need the cast (int) attr (although it's not wrong), and whoever gave you that assignment must be a very evil person to make you do all that casting
There are so many things that could go wrong there that you might as well just use a dynamically typed language
What is the purpose of T if you're just going to cast it? Why not just use Object? Why does it print something instead of throwing an exception? How is a caller to know that they gave the method the wrong arguments? AHHHH!!!1
@hyper-neutrino I hate the boilerplate and I hate how other people use it, but yeah, it's one of those things that people hate because other people hate it
(clarification: I also hate how I use Java, I always end up writing crappy code. Not discriminating here)
it's just really verbose. especially with frameworks it's kind of nice for larger / scalable projects but i'd still just rather use something else lol
half of the time i use java it's trivial stuff anyone could write, and the other half of the time i end up throwing together some weird hacky thing with three templates just to get one small thing to work
+1 for python too; it has a lot of stuff I dislike about it but it's able to be golfy, it's pretty concise even without being unreasonable with golfing it, and it's quite readable
[x ** 2 for x in a] makes sense to me but it's also pretty concise
better than java.utils.Arrays.stream(a).map(x -> x * x).toArray(int[]::new) anyway
If you're doing math stuff on arrays, I'm assuming you have java.util.Arrays already imported, so you can do Arrays.stream(a).map(x -> x * x).toArray() (an IntStream doesn't need the int[]::new part)
What is better, Python or React? Can you please specify its use and some places to find much more info? Can we build a backend with React? Suggest me some places to learn them, are website and mobile apps and PC apps buildable by react or python?
I would also appreciate that if you could give me ...
@cairdcoinheringaahing I love how people find Stack Overflow, somehow navigate to MSE, make an account, draft a question, review it, and still post this kind of stuff
@cairdcoinheringaahing yeah, I'm not surprised that this works; it's what i'd expect anyway
and yes, & is partial compose
for whatever reason import random for (i : 1..10) print(random.random()) works but import random; for (i : 1..10) print(random.random()) doesn't
one of the most cursed things i allowed in proton was that if something can't be parsed in this expression it just becomes a new expression so import random f = random.random for (i : 1..10) print(f()) is allowed
@Neil just puns on particle physics. the "uncertainty principle" says you can't know a particle's position ("where it is") and velocity at the same time.
tags: code-golf sequence
Based square-free words
A square-free word is a word that contains no squares, i.e. contains no adjacent repeating subwords. For example, 0123 is square-free, while 0112 and 012123 are not (because 11 and 1212 are repetitions, respectively).
In base-1 there is only one sq...
@user not an assignment though. It's 100% an experiment by me - I wouldn't have given you the whole file otherwise. T is so I can pass any type to the set Attribute because it could be a string or integer or float. The type casting is because a) it required me to use non-primitive types (Java did) and b) switch no like Integer
btw, please don't take anything I said before personally - I thought a proper Java professor suggested that and didn't realize it was just an experiment
@RedwolfPrograms I guess if it's an integer, you could turn it into a list of digits, and if it's a list of integers, you could turn each into a string, concatenate, and turn back into an integer?
A slightly more mathematical construction would be something like this: 1) establish bijection between N and N^n for any finite n (N^1, N^2, N^3, ...) 2) Map each integer list into a pair of integers (n, result of N^n->N) and then apply Cantor
Btw you can just do 69.420f, which is a float, and it'll usually be automatically boxed to a Float. Also, you don't need to explicitly give type arguments to setAttribute, since Java has (rather limited) type inference
Also, if you're using pounds, Joe and Not Joe seem to be dying of starvation
There's a joke to be made here, but I can't see it because of Joe Mama
It is known to be implemented in Dyalog APL, J, and NARS2000. You are not allowed to use floor/ceiling/residue/GCD/LCM functions with non-real complex arguments for these languages. aww, no 1 byte answer
should have been there for at least like 10 or so minutes based on # tabs and when the reopen vote came in (can't give an exact time since idk if CV/VTRO is available on the public timeline)
@okie rather than editing out the profile some mods have started appending "spam" to the username and #spam to the URL so that other mods can detect them using the same patterns but can also just look for spam in the mod search
@cairdcoinheringaahing maybe queues showing diff stuff to ppl or something? idrk. i think you mentioned something about that but i have no clue how anything to do with SE works ¯\_(ツ)_/¯
it was hammer closed by WW (2 votes + mod) so IDK if it shows it to mods first or something. that could make sense but i also somewhat doubt it because moderators aren't exactly supposed to unilaterally do everything, the community has just as much of a hand in moderation as we do
i think redwolf finds an old thing, realizes it's unclear, you probably find it in the queue with RSR/GRT or through black magic (or vice versa), and then a mod notices it and hammers it