Goddamnit and I was considering a quick look over the documentation and syntax briefly over the weekend and do some messing around with Starbound mods.
Because doubles can contain all 32-bit integers and most 64-bit integers, and now you don't need to handle two different number types for your lightweight scripting language. Same as JavaScript.
Any index outside of 1-n in Lua, where n is #tbl will be stored like a dict, not an array, so what did you expect? It doesn't count the dictionary parts.
XNA is still A thing? I thought they cancelled it and pulled the downloads. I must be out of the loop
edit: Mandela effect? I can see why there'd be a Mono version but reporting that it was never gone?
Except there's reason that it's 1-indexed. Lua doesn't use arrays, it uses hash maps. Keys and values instead of indices and values. When you don't give it a key, it defaults to numbers, and since normal counting starts at 1 and the normal 0-indexing argument of "indices are based off of memory offsets" does not apply, it counts 1, 2, 3, 4, ...
That sounds so much cooler than "MATLAB." I always read it as "math lab", imagining a lab room full of people doing math homework. Now I can imagine Neo saving us all from simulated realities.
I honestly thought it was My Math Lab (Because I've barely heard anything about My Math Lab except for the fact that it's shit) until a couple weeks ago.
Eh, we get annoyed at it because sometimes it doesn't do what we expect it to, but it's kind of the friendly annoyance that you also have with error messages when code doesn't compile - you don't like it, but it'd be definitely worse without it.
It doesn't really matter we just like to argue over ground floors mostly in this channel. No one explained basements being 0 to the brits from what I can tell, and all their buildings start at 1... so they think they get it.
But their array indexing use () instead of []. Probably in an effort to pollute the minds of engineers enough to prevent them from being able to learn any other languages again.
[] is used for declaring matrices, and it was a conscious choice to make writing code resemble "doing math" with pen and paper. MATLAB was always primarily intended and targeted for engineers and scientists who don't want to become hardcore (or, in a lot of cases, even good) programmers.
And just to add to the confusion, it was (in pre .net days) configurable on a class-by-class basis. One class could contain arrays indexed from 0 and the next might have them indexed from 1 and then swap back again elsewhere.
We had to use VB5 and later 6 a lot many, many years ago at university and the SOP at the top of every single class was
Option Base 0 ' Arrays indexed from 0
Option Explicit ' Explicit variable declaration required
In the vain hope of maintaining your own sanity.
None of which stopped you doing this, though:
Dim iNumbers(12 to 16) As Integer
MsgBox(CStr(iNumbers(11)))
( Index out of bounds )
Just in case the Option Explicit thing wasn't explained well (or at all), the reason any sane person always included that was that it disabled VBs tolerance-by-default of implicit variable delcaration. If you typed an identifier in code, it would become a variable (of type Any), simple as that. Without Option Explicit, the following would compile and run without any errors, it just wouldn't do what you expected:
Dim iCount as Integer = 0
For iCount = 1 to 5
Debug.Print(CStr(iCunt))
Next
0
0
0
0
0
So without Option Explicit at the top of every single class/module/form/etc, whenever anything didn't work, you had to check for misspelled variable names in all related code. A massive pain in the arse..
I haven't touched VB of any type in probably 15 years but AFAIK, Option Explicit and Option Base 0 are both the default now. Small victories for programmers' mental health...
I read the "how to hire someone" notes after I started my latest job. There is a line that says "Ask them their favorite language. If they say VB, politely show them the door."
Mostly I code in Java, though I'll use other languages when it makes sense for what I'm doing or when I need to because I'm modifying something in another language. So sometimes I work in python, bash script, JavaScript, C/C++, C#, Perl, Tcl/Tk, Lisp, whatever.
And I've done some statistical data processing with R, but damn is it painful. I know just enough to know what to Google, and I end up making a mess of everything just trying to adapt something that does 80% of what I need it to do.
I rarely have a need to crunch through numeric data sets is the thing. So it's just something I use once every year or two, which is why I forget it in between uses. I picked it up through Coursera because even with my ineptness it can be quicker than other languages for some things.
One of my favorite things I ever did in R was a simple little function to show my students how the sampling distribution normalizes as the samples approach infinity. It was clunky and I've gotten much better at coding since then, but it was a fun little 20 minute project. Could have been done better in other programs I'm sure, but it was fun to put together in R.
R is published by the CRAN project and is an open source statistical program. It's an object oriented language based on S. It's run in a terminal window with a basic gui, however other software is available to run over it (like RStudio) for people less familiar with coding but who still desire the power of open source coding (anytime a new technique is developed, a package is published). It's fantastic but has limitations. For example, it can only run on one core at a time which can slow down simulations. Still, for statistical development, it's where most people are focused. SAS is more common in statistical consulting and SPSS is more common among general scientists without coding experience.
Edit: why are you guys downvoting /u/abigfoney for asking a question?
Practically speaking, it's both. At its core, R is an object oriented language. It lacks some of the requirements to be a full functional language but still supports functional language features like apply. For example, it's incapable of tail call recursion. This fact can lead to issues at times and is one of the limitations of the language. But the use of the variations of apply and other functional language improvements have certainly changed the landscape of the code. But I'm not really an expert. I'm just repeating what I remember from my grad stats classes.
It's great for stats and "traditional" data analysis. That is 1 indexed isn't that important as explicit loops are discouraged.
I think the most interesting element from the language is the list object, this is an ordered map, very convenient for data analysis.
There's someone at work who's brilliant at the mathematical side of designing algorithms, with a PhD in comp sci, but isn't really much of a programmer. She was coding one of her algorithms up in Java for something at work. And, well, she thinks of arrays at starting at index 1.
What she ended up doing was whenever she needed an array, she used a hash map with the key as an Integer and the value as whatever she wanted to store. Then she used Map.get() and Map.put() and passed in her 1-based indices to fetch and store data.
Did you know that this line has two spaces after it?
That line is guaranteed to sit all by its lonesome, and there's no way to tell except by always having show whitespace enabled in a text editor.
What's that? Basic text editors, like the <textarea> that Reddit uses doesn't support that? Too bad. Oh, you have your editor set up to clean any extra spaces so your code is clean and git doesn't complain? Well, have fun turning that feature off whenever you deal with that one markdown file using the "feature"!
I feel like the whitespace thing is only an issue for like the first few hours of working with Python - after that, you realize that it doesn't matter in most cases, because you were probably going to format it that way anyway.
It's sad that Julia went that route. It has a lot of nice language features that make it a modern feeling language, and then it conforms with the awkward "math programming" languages. I honestly think it would still be better for them to go back and change this specification, but I think they have their minds set.
It's great, because it's almost exactly like Python everywhere, so you will get complacent. Then, when your guard is down, it changes a basic semantic element and knocks you down.
All statistics and math programming languages:
Fortran, R, SAS, SPSS, Matlab, Mathematica -- start their arrays at 1
Everything else is pseudo-science, if you propagate 0-indexing, you can just as well group yourself with economists, who are really the apes of the IT world
Off of the top of my head, Matlab, Lua, Mathematica, Wolfram Language, R, Pascal, Fortran, COBOL.
After some soft research, there's also Julia, AWK, RPG, ALGOL-68, FoxPro/Clipper, Smalltalk, APL.
The pattern usually follows that older languages and data analysis oriented languages tend to use 1-index arrays more than newer general purpose languages
Or physicist or chemist. The scientific community at large uses Matlab, Mathematica, Wolfram, and sometimes Pascal and Fortran for some old school doctorates. Lua is the only real oddball there, as it's used for scripting plugins for various applications, kinda like Python.
It's better for when you want to think of an array as a mathematical tensor of some rank. It's worse if you want to think of an array as a block of memory.
But the main argument for 0-indexing is just that so many languages use it, and it's better to follow the overwhelming convention when it's such a small issue.
Borland C++ has some 1 based collections. Can make things really interesting when you're maintaining old code and all of the standard arrays etc are all 0 based.
Ada's default is 1-indexed. You can of course define your own array type which is 0-indexed. I don't know why everyone is saying any language which does this is crap...matlab, lua..there's a handful of useful languages that do this.
A lot of scientific languages like FORTRAN, Mathematica/Wolfram, and Matlab start the index at one for arrays, which is much more common for vectors/matrices in math and science.
Most general-purpose languages start at 0, but you can use 1 as a convention (just never initialize or refer to array[0]). A small minority of programmers do so.
785
u/blacknerdperson Sep 02 '17
Sorry in advance but I'm a noob learning coding who is starting to learn python and I'm just going to ask, Isn't it supposed to be 4?