4 ms·
That may be the correct way, e.g., if you do a lot of list squaring, and if you don't square other things a lot. Even in this case, I'd prefer something like
by euccastro 19y ago
That may be the correct way, e.g., if you do a lot of list squaring, and if you don't square other things a lot. Even in this case, I'd prefer something like
dest = mapsquare(src)
Consider the possibility that C-like syntax and mixedCaseVerboseNames may be an acquired taste.
If you do square a lot other things than lists, it's probably best to say
dest = map(square, src)
For one-shot usage where defining square seems overkill, and where it's available and idiomatic, I find the list comprehension most readable.
- mynameishere 19y agodest = map(square, src) Well, this is okay. Of course, in java, you have to hack it unpleasantly, List dest = map(UtilityMethods.class, "square", src) ...you have to manually extract the method "square" from UtilityMethods.class and process it over src. One advantage: You can use UtilityMethods as a namespace and swap in different methods thereby.