5 ms·
Like ⌹? I wonder what it means. There's all these APL symbols in Unicode and I don't understand what they mean. But they never look serious enough to make me wa
by squiggleblaz 7y ago
Like ⌹? I wonder what it means. There's all these APL symbols in Unicode and I don't understand what they mean. But they never look serious enough to make me want to learn the language. I guess the modern APL character soup is Haskell where people can propose (but never implement) something like ⟦ xx ∋ yy ⟧ which looks vastly more serious and any stranger can immediately grasp its meaning, a trait shared with every ascii alphabet soup programming language in the world.
- robomartin 7y agoIf you look at the symbol, it looks like a rectangle with a division symbol inside. A rectangle is reminiscent of the shape of a matrix. This is what it does: Monadic form: Matrix inverse. a ← 3 3 ⍴ ⍳9 a 1 2 3 4 5 6 7 8 9 ⌹a ¯4.849821517E14 9.699643034E14 ¯4.849821517E14 9.699643034E14 ¯1.939928607E15 9.699643034E14 ¯4.849821517E14 9.699643034E14 ¯4.849821517E14 Dyadic form: Matrix division. b ← 1 2 3 b ⌹ a 0.7357839757 ¯1.471567951 1.069117309 To put this into context, say you have a set of linear equations with three unknowns, x, y and z: -8 = 3x + 2y - z 19 = x - y + 3z 0 = 5x + 2y We want to solve for x, y and z. Matrix division is the answer. First we grab the coefficients and stuff them into a matrix: c ← 3 3 ⍴ 3 2 ¯1 1 ¯1 3 5 2 0 c 3 2 ¯1 1 ¯1 3 5 2 0 Next we assign the constants to a vector (which can also be considered a 1x3 matrix): k ← ¯8 19 0 k ¯8 19 0 Note that APL uses the "high minus" to denote negative values in order to avoid confusion with negation "-". For example: -1 2 3 yields: ¯1 ¯2 ¯3 If you only wanted a negative 1 the correct syntax would be: ¯1 2 3 Anyhow, we now have: k ¯8 19 0 c 3 2 ¯1 1 ¯1 3 5 2 0 In order to solve the system of three simultaneous equations with three unknowns we just need to use matrix division: k ⌹ c 2 ¯5 4 The answer is a vector where the elements correspond to x, y and z, respectively. This will work so long as the matrix has an inverse and will work for a system of n equations with n unknowns. Incidentally, if we want to keep all three equations, constants and coefficients in a single matrix we can do that just as well: d ← 3 4 ⍴ ¯8 3 2 ¯1 19 1 ¯1 3 0 5 2 0 d ¯8 3 2 ¯1 19 1 ¯1 3 0 5 2 0 We can then use the same matrix division expression to solve the system of equations by slicing-up the matrix to get our constants and coefficients: This "take"s (↑) the first column from the matrix (along the second dimension, hence the [2])... 1↑[2]d ¯8 19 0 and this takes the last three columns: ¯3↑[2]d 3 2 ¯1 1 ¯1 3 5 2 0 You can also "drop" (↓) the first column, which is a better idea because this makes the code independent of the size of the matrix: 1↓[2]d 3 2 ¯1 1 ¯1 3 5 2 0 Plugging into the prior expression of this form: k ⌹ c we would have: (1↑[2]d) ⌹ 1↓[2]d 2 ¯5 4 This gives us a 3x1 matrix as the result. If we want a vector all we need to do is add the "ravel" operator "," (the monadic form of concatenation) on the left: ,(1↑[2]d) ⌹ ¯3↑[2]d 2 ¯5 4 Or, we could, if it made sense "laminate" the column vector result on the back side of the matrix so that we have constants, coefficients and the solution vector all in a single variable or data structure. Like this: d ← d,(1↑[2]d) ⌹ ¯3↑[2]d d ¯8 3 2 ¯1 2 19 1 ¯1 3 ¯5 0 5 2 0 4 That gives us everything in a nice tight package that we can use for other work. Extracting the various elements from this matrix is easy: Constants: 1↑[2]d ¯8 19 0 Results: ¯1↑[2]d 2 ¯5 4 Coefficients: ¯1↓[2]1↓[2]d 3 2 ¯1 1 ¯1 3 5 2 0 or, using indexing instead of sequential "drop" (the disadvantage being that the "drop" approach is independent of matrix size): d[;2 3 4] 3 2 ¯1 1 ¯1 3 5 2 0 If these concepts are foreign to you, google "solving simultaneous equations with linear algebra". It's neat stuff.
- m463 7y agoYou have posted an amazing and comprehensive comment. > If you look at the symbol, it looks like a rectangle with a division symbol inside. If you skip exactly 20 minutes into this video it IS EXACTLY a rectangle with a division symbol inside: https://www.youtube.com/watch?v=_DTpQ4Kk2wA https://www.youtube.com/watch?v=_DTpQ4Kk2wA I don't know whether to think "thank goodness for unicode" or "unicode is an enabler of problematic practices" :)
- robomartin 7y agoI got started in the early '80's, 1982 if I remember correctly. I actually used a teletype for a (thankfully) very short period of time --just like what the presenter is using in this video. In the most primitive early days you had to type two characters, the rectangle and then go back and type the division symbol. Again, thankfully, that lasted a very short time for me. What most people do not realize when they discuss APL today is that back in 1962 and going into the mid to late '80's APL was an incredibly advanced tool when compared to almost anything available at the time. I mean, people were programming in Fortran, Cobol, C, Forth, Lisp, Basic and a few other languages. They were incredibly primitive when compared to APL. I was doing crazy multi-dimensional array work in physics that would have required massive amounts of C code to implement, not to mention that I could type a few lines of code that represented weeks of development in other languages. It is easy to be critical of APL today and not realize that its creation back in the '60's and usage for the next 20 to 30 years was sheer genius. Today most of these capabilities are not found as inherent parts of languages but as an array of domain specific libraries. The tool-set available to an APL programmer back around the time of this video and for the next decade (at least) was without comparison in the world of computing. I am very glad to have been shoved into an APL class in college. It made a huge difference in my life and taught me to think about computing in a very different manner.