Readit News logoReadit News
improbable22 commented on Swift for TensorFlow Shuts Down   github.com/tensorflow/swi... · Posted by u/high_derivative
ZephyrBlu · 5 years ago
What I mean is something like this:

    # one dimensional
    a = [1, 2, 3]
    # prints the number 1 @ index 0
    print(a[0])
    
    # multi-dimensional
    b = [[1, 2, 3], [4, 5, 6]]
    # prints the number 4 @ index (1, 0)
    print(b[1][0])
In Julia these indexes would start from 1. It doesn't seem like `CartesianIndex` solves this, since looking at some examples you still have to specify array indexes (Which start from 1): https://docs.julialang.org/en/v1/base/arrays/#Base.Iterators...

improbable22 · 5 years ago
OK, I thought you were advocating zero based on complicated index calculations for some algorithm, with mod & div, which is what I was trying to say could be abstracted away. The literal syntax `a=[1,2,3]` makes a one-dimensional `Array{Int,1}` whose first element is indeed `a[1]`. (`b` is an array of arrays, while `c = [1 2 3; 4 5 6]` is an honest 2-dimensional array.)
improbable22 commented on Swift for TensorFlow Shuts Down   github.com/tensorflow/swi... · Posted by u/high_derivative
ZephyrBlu · 5 years ago
I'm not 100% sure what I'm looking at, but that seems to be related to reversing arrays/matrices, not accessing arrays through indexes.
improbable22 · 5 years ago
Maybe less readable than I remembered, sorry! But these `CartesianIndex` things are how you index multi-dimensional arrays.

If by indexing you only mean adding offsets to pointers with your bare hands, this is possible but discouraged. Because you'll produce a buggier and less general version of exactly what already exists. In this case, reversing an N-dimensional array, along any M of its axes, with arbitrary offsets -- there are a lot of ways to get that wrong.

improbable22 commented on Swift for TensorFlow Shuts Down   github.com/tensorflow/swi... · Posted by u/high_derivative
ZephyrBlu · 5 years ago
You still need to access indexes if you're working with arrays though, which is a very common data structure.
improbable22 · 5 years ago
That's not so obvious, the abstractions for multi-dimensional indexing are better than (I think) you're imagining.

Here's a nice recent example: a new reverse!(A; dims) function, which is fast and works on arrays with any number of dimensions. And is completely indifferent to where the indices start:

https://github.com/JuliaLang/julia/pull/37367/files#diff-eb9...

improbable22 commented on The people the suburbs were built for are gone   vice.com/en/article/y3gx5... · Posted by u/elsewhen
Bob_LaBLahh · 5 years ago
It doesn't have to be that long. My mom asked the city to put in some oak trees when I was a kid. It only took the trees about 15 years to grow to a pretty good size. In my opinion, it's worth the effort of lobbying the city.
improbable22 · 5 years ago
My parents did it the unofficial way, put in 5-10 trees along the road, over a few weekends, with the same style of concrete surrounding that the city used. They are huge now, and nobody ever questioned how they got there. Not 50-years huge, and a faster-growing species than oak, but still a big improvement.
improbable22 commented on Again on 0-based vs. 1-based indexing   hisham.hm/2021/01/18/agai... · Posted by u/Ivoah
teekert · 5 years ago
Yeah and kids are actually aged "1" in their second year.
improbable22 · 5 years ago
Time is a continuous variable, and kids know this pretty early on: they will happily tell you they are 5 and a half years old. Their second year starts when they are aged 1.0.

English in general makes this distinction: "He is fewer than 6 years old" is simply a mistake, while "less than 6 years old" is fine. (I think some dialects use "fewer" less often, in general, but would be pretty surprised if any prefer it here.)

improbable22 commented on Again on 0-based vs. 1-based indexing   hisham.hm/2021/01/18/agai... · Posted by u/Ivoah
teekert · 5 years ago
Well, I was born aged 0, turn 1 at the start of my second year on the planet.
improbable22 · 5 years ago
If you ask kids how old they are, you will often get "5 and a half" etc. They are, correctly, thinking of time as a continuous variable. You "turn 1" when your age reaches 1.0.
improbable22 commented on Again on 0-based vs. 1-based indexing   hisham.hm/2021/01/18/agai... · Posted by u/Ivoah
tremon · 5 years ago
Mathematica is also not a low-level programming language. It's math-based, so it deals with abstract concepts, not concrete hardware implementations.

0-based arrays are based on hardware implementations; 1-based arrays are based on abstract collections; you could make the argument that 0-based arrays are a leaky abstraction, but the question then becomes: what abstraction? C explicitly tried not to abstract away the underlying hardware.

improbable22 · 5 years ago
If "any language" means "any language sufficiently low-level to have C-like pointers", then no contest!

Surely the point of any language at all is to abstract away some details of the underlying hardware. Both for portability and to make things easier for human brains. How much you should abstract away obviously varies, based on what you're trying to do, and on how varied the hardware is.

And it depends on how much computation & memory you can give your compiler. One reason new languages can have nicer abstractions is that they don't have to compile on 1970s hardware.

improbable22 commented on Again on 0-based vs. 1-based indexing   hisham.hm/2021/01/18/agai... · Posted by u/Ivoah
tpush · 5 years ago
A pointer (or reference, or just 'address') is a general concept that by definition is part of any language featuring mutation.

Any language that makes use of mutation for primitive constructs (not saying that's the case here specifically) needs an understanding of "observing/causing change" pretty early on.

improbable22 · 5 years ago
> is a general concept that by definition is part of any language featuring mutation.

One counter-example is Mathematica. I can mutate any object any time I like, and doing so is extremely common. Yet under "pointer" its help tells me about some unicode symbols, and some GUI stuff about mouse pointers.

In reality, some of its lists are dense memory like C, some contain arbitrary objects (such as expressions, or high-precision numbers), but these implementation details aren't part of the language, and most users never know them.

improbable22 commented on Maps.me is gone, and we must bring it back   telegra.ph/What-happened-... · Posted by u/monort
Mediterraneo10 · 5 years ago
Most of the aerial imagery used in Europe for improving OSM is shot from planes, not from space.
improbable22 · 5 years ago
> Most of the aerial imagery used in Europe for improving OSM is shot from planes

Yes I know, and not just Europe. But my comment there was specifically about contours, i.e. height data from SRTM. I'm not aware of any project to crowd-source stereo-pair contour drawing, but if you know of one, I'd be interested to have a link.

improbable22 commented on Maps.me is gone, and we must bring it back   telegra.ph/What-happened-... · Posted by u/monort
Ayesh · 5 years ago
Most of the hiking maps are simply not even on Google maps. Only in OSM
improbable22 · 5 years ago
It depends a lot where you go. In places like Nepal OSM is often better than any map you can buy. In the Europe and especially the US, it's not as detailed as the national maps. They usually also have much better contours (drawn from aerial photos not from the space shuttle).

But still much better than Google maps, which seems very much for cars (at least outside of cities).

u/improbable22

KarmaCake day677January 8, 2017View Original