It appears a lot of my inspiration for writing blog posts comes from me listening to podcasts. This time I was listening to A Problem Squ...| Elias Mårtenson
This weekend I was listening to episode 99 of Array Cast. The topic of the fortnight was array indexing, or the way to read values out of arrays. A programmer unfamiliar with array languages may wonder how such a simple concept can fill an entire hour-and-a-half episode (and they may even have to extend it to another episode), and to answer that question I would recommend listening to the episode, but the short answer is that array languages focus on organising data in arrays and then perform...| Elias Mårtenson
This is a short update to my previous post where I will solve the second part. At the end, I will also include one-line solutions to the two problems, which really doesn't involve more than removal of unnecessary variable assignments. Revisiting part 1, here's the full solution that was written in that post (with a few less variable reassignments): numbers ← ⍎¨ ⊃ {(@\s≠⍵) ⊂ ⍵}¨ io:read "part01.txt" (a b) ← ⊂[0] numbers a ← ∧a b ← ∧b +/ | a - b Solution to part 2 Le...| Elias Mårtenson
So Advent of Code is done, and I made an actual effort this time. Of course I used Kap, and the final tally ended up being 32 out of 50 stars. I may solve some more later if I feel bored. The Advent of Code problems tend to be very good fits for array languages, and array language solutions are often much shorter than solutions in other languages. In particular, the parsing which is often annoying in many languages often reduce down to a few characters in Kap. Let's take a look at day 1 and s...| Elias Mårtenson
You may have heard about how array programming languages such as APL, J or K. If you have, you've probably heard that code written in these languages is incredibly dense and unreadable. "Line noise" is a term often used to refer to them. In this post, I will try to use Kap to give an introduction to the language by using an imperative programming style. Actual Kap code is a mix of terse and verbose styles, but perhaps illustrating the verbose style first provide a different perspective. If yo...| Elias Mårtenson
It has been said that the most popular programming language in the world is the spreadsheet (and in particular these days, Excel). There...| Elias Mårtenson
@loke@functional.cafe Kap has a datatype called a list which is container that can hold 0 or more values. The list itself is a scalar (i.e. ⍴ on a list returns an empty array). The origin of the idea of the n-tuple type comes from the APL bracket index syntax: a ← 3 3 ⍴ ⍳9 a[2;1] 7 It all came out of the idea that I didn't want special syntax for the argument to an axis index operation, so I made 1;2;3;4 an object of its own. This is the n-tuple. a ← 3 3 ⍴ ⍳9 b ← (2;1) a[b] On...| Elias Mårtenson
I'll start by commenting on what was said at the at the end of the episode of Array Cast with the title Tacit#5: They implied that the episode was long, and people probably wouldn't make it to the end. In case any of the hosts are reading this: I know it was mentioned that you didn't want to hear if anyone felt the show was too slort. I'm going to say it anyway: The show is too short. Please make it at least 4 hours. Deriving a function vs. returning a function In the episode, there was a dis...| Elias Mårtenson
A number of years ago I noted that Unicode did not contain all the characters in PETSCII, the character set used by the Commodore 64 and other classic Commodore computers. The Wikipedia page at the time even explained that some symbols were missing in their character table due to the fact that Unicode didn't support them. I decided to make a post about it to the Unicode mailing list, and some people there agreed. The discussion expanded to talk about other 80's systems whose character sets we...| Elias Mårtenson
Until now, the only way to return a value from a Kap function was to have it be returned as the return value from the last expression in a function. Well, there are also exceptions, but those a bit special and should, well, exceptions. But in some cases it's useful to return a value early. Essentially what return is in languages like C, Java, etc. So, I did the obvious and implemented return just like in those languages, except that it's called → to align with APL. This example%20%7B%0A%20%...| Elias Mårtenson