4 ms·
Most people think of one of the MS BASIC dialects when they think of BASIC (at least in the US). The original Dartmouth BASIC had matrix primatives, including M
by tasty_freeze 2y ago
Most people think of one of the MS BASIC dialects when they think of BASIC (at least in the US). The original Dartmouth BASIC had matrix primatives, including MAT READ, MAT PRINT, MAT INPUT, and functions like MAT A=INV(B) (yes, matrix inversion), MAT A=BC, MAT A=B+C, MAT A=B-C, MAT A=B(2) (scalar mult), MAT A=TRN(B) (transpose), MAT A=IDN(5,5) (5x5 identity matrix), MAT A=ZER(5,5) (zero), MAT A=CON(5,5) (fill with 1.0).
I cut my teeth on Wang 2200 BASIC, which was an extended Dartmouth BASIC, so it had the above MAT statements, but also a bunch of wild ones that did searching and sorting on arrays, merging two sorted arrays into a sorted output, and more.
Here is a statement that searches a character array A$() in columns 1-5 for a string in Z$: MAT SEARCH A$()<1,5>,=STR(Z$,1,5) TO B$ STEP 5. Every match writes the location to a descriptor array (this case B$), where each pair of bytes was the offset in the A$ array where the match was found.
Despite all that power, it still was quite limited: all variable names had to be a single letter or a letter and a digit. All variables were global. GOTO and GOSUB were either the line number or a "label" where the label was one of '0 to '255. Strings were statically allocated, not dynamic, and the max length was 64 characters (BASIC-2 extended that to 126 bytes). On the other hand, before the program started running everything was allocated there was no possibility of memory overflow during runtime, and no garbage collection, and any references to missing line numbers was caught up front.