norden.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Moin! Dies ist die Mastodon-Instanz für Nordlichter, Schnacker und alles dazwischen. Folge dem Leuchtturm.

Administered by:

Server stats:

3.2K
active users

#programming

191 posts161 participants0 posts today

I've been unemployed since 2023 or so, so I haven't gotten to use LLMs at work much yet. I'm actually kind of excited for it; I'm far more dangerous now. Maybe I can be one of those 10x devs who brings down prod on a Friday because he's refactoring the whole codebase for no reason!!

#ai#copilot#chatgpt

Today in “things that are obvious, I just didn’t know them”

If you’re building a web proxy, never forward the Host header. It will screw up SSL verification and the error message won’t tell you why.

Continued thread

The original rule was simple: The resulting array has the same dimensions as the input, but the reduction axis removed. So if you have a 3-dimensional array of dimensions 2 3 4 and reduce along the last axis, the resulting array will have dimensions 2 3.

The change that I have now implemented introduces a new rule that says the following:

If the input array is 1-dimensional, the result is disclosed.

A 0-dimensional array has a single element. disclosed simply means that whatever was in the 0-dimensional array is returned.

In practice, this is what you want in almost every single case, so it removes a lot of useless calls to (the disclose function).

Now, both Kap and APL has an alternative reduction operator: . In APL, and Kap previously, this operator works exactly the same as /, just that is applies its operation on the first axis rather than the last. If you use the explicit axis specifier with the operator (the axis number inside square brackets), these functions behave identically.

Now, in Kap, the operator does not have the special rule, which means that if you really want the APL behaviour, you can still use this operator. This behaviour has been borrowed from dzaima/APL (link).

I had to change some of the example code to the this change into account, and there is probably more code that I need to change. Oh well, I still think this will make using Kap much nicer.

aplwiki.comdzaima/APL - APL Wiki

So, I made a language change to Kap today. It's one of those breaking changes that I wouldn't be able to do if I had users running actual code. 🙂

I changed the behaviour of the reduction operator (/) to be more useful when the argument is a 1-dimensional array. The old behaviour was compatible with APL which, I have convinced myself, is not ideal.

In APL, the reduction operator acts on an array of any dimension and applies a function repeatedly on elements across a given dimension, returning an array with one dimension less than the original.

An example will make this easier to see. Let's say you have a 2-dimensional array:

    3 4 ⍴ ⍳12
┌→────────┐
↓0 1 2 3│
│4 5 6 7│
│8 9 10 11│
└─────────┘

Then, we perform a row-wise reduction over the function + on this array. That's another way to say that we sum each row:

    +/ 3 4 ⍴ ⍳12
┌→──────┐
│6 22 38│
└───────┘

Note how the 2-dimensional array became a 1-dimensional array. By reducing the array along one dimension, that dimension was removed and replaced with the sum in this case.

OK, let's see what happens when we reduce a 1-dimensional array:

    +/ 1 2 3 4
10

We reduced a 1-dimensional array to a scalar value. A scalar has 0 dimensions.

So far so good. But now let's reduce using a different function. The best example is the , function, which simply concatenates arrays. So "foo" , "xyz" becomes "fooxyz".

Let's create a 2-by-2 array of strings (a string is just a 1-dimensional array of characters):

    2 2 ⍴ "abc" "def" "ghi" "jkl"
┌→──────────┐
↓"abc" "def"│
│"ghi" "jkl"│
└───────────┘

Now let's do a reduce using ,:

,/ 2 2 ⍴ "abc" "def" "ghi" "jkl"
┌→────────────────┐
│"abcdef" "ghijkl"│
└─────────────────┘

Great, we've reduced the 2-dimensional array to 1 dimension.

Now, the big question is: What should happen when you reduce a 1-dimensional array of strings using ,? To remain consistent, the result must be a 0-dimensional value. I.e. a scalar. This is what happens in APL, and what used to happen in Kap as well.

1/2

This is the current weather using wttr for the PBM Airport in SR / SA

As you can see wttr has a very flexible manner of asking for weather, is opensource, has a lovely API and can be used in countless manners. For me the fact that I can call it up from bash (and any shell) is smooth nice and amazing

#weather#wttr#curl