News for hackers. Stuff that matters.
Re:Fascination of Awk by NoboruWataya on Friday March 24, 2023 @12:13PM (#35291194)
Agreed - this is pretty much the perfect use case for list comprehensions, which are one of the best features of Python. Normally "oh but there's a better way to do it in that language" isn't a particularly interesting observation, but here it completely turns the author's point on its head. I can't think of many more elegant ways to convert a list of ints to floats, in any language, than `[float(i) for i in integerlist]`.
Re:Fascination of Awk by chillpenguin on Friday March 24, 2023 @12:57PM (#35291973)
I agree. But regarding

> I can't think of many more elegant ways to convert a list of ints to floats, in any language, than `[float(i) for i in integerlist]`.

I think something like `integerlist.map(float)` is at least a contender.

Re:Fascination of Awk by pcthrowaway on Friday March 24, 2023 @05:39PM (#35295970)
I prefer the python syntax generally, but throw in some typing with Typescript inferring the post-map type from the map function's return type, and I'd definitely go with `integerlist.map(float)`
Re:Fascination of Awk by enriquto on Friday March 24, 2023 @02:31PM (#35293524)
> I can't think of many more elegant ways to convert a list of ints to floats, in any language, than `[float(i) for i in integerlist]`.

What about `float(integerlist)`

Re:Fascination of Awk by nawgz on Friday March 24, 2023 @03:57PM (#35294598)
I don't think writing a function called `float` that apparently accepts arrays as an argument is very elegant at all