Re:How to Use Em Dashes (–), En Dashes (–), and Hyphens (-)
by econ on Thursday March 27, 2025 @10:49PM
(#43500958)
I've always wanted an array or object with range keys like:
arr[0–2] = 123;
if(arr[1.5555]>122){}
[ Parent
| on HN ]
Re:How to Use Em Dashes (–), En Dashes (–), and Hyphens (-)
by paulddraper on Friday March 28, 2025 @01:08AM
(#43501747)
In Python it’s a colon.
Re:How to Use Em Dashes (–), En Dashes (–), and Hyphens (-)
by econ on Friday March 28, 2025 @11:52PM
(#43512579)
Nice, covers at least some of the abstraction "problem".
Re:How to Use Em Dashes (–), En Dashes (–), and Hyphens (-)
by yesbabyyes on Friday March 28, 2025 @03:59AM
(#43502720)
That doesn't seem to be an array at all, if the idea is to check whether a number is within a range. Seems like an interesting data type though, a combination of a range data type and a map/associative array.
Re:How to Use Em Dashes (–), En Dashes (–), and Hyphens (-)
by econ on Friday March 28, 2025 @11:51PM
(#43512575)
I was thinking of a sparse array but any name will do. obj[~42] ?
One may have a bunch of key ranges each associated with a value or one may have a key that should be "rounded" to the nearest key or retreave the one below or above it.
It feels like something basic enough to have in a language and I found it oddly complicated to write myself. Comparing it with all values doesn't seem like a very good solution.
Not that I know many languages.