1. 54
nsl.com
1. 4

What does the expression at the end mean?

Looking at the manual it looks like `|` is Max/Or. I also saw that |/ is defined as “Max-Over”?

1. 7

It’s the K implementation of the algorithm above. Find the max of a list of numbers.

1. 1

Ah, for some reason I thought it was a pun to the effect of “hah, you noobs”.

2. 6

| is max. It’s also boolean or. If you wanted the minimum, it’d be `&/`, because `&` is min/boolean and.

The APLs have teased apart lots of common operations into atomic parts that combine cleanly, sometimes unpacking them further than other languages go. The single-argument form of & (“where”) is a good example:

``````  &1 2 3
0 1 1 2 2 2
``````

It counts up, repeating each successive number based on the next number in the argument.

``````  &5 5 5
0 0 0 0 0 1 1 1 1 1 2 2 2 2 2
``````

Okay, so that makes the pattern clearer. By why is that useful?

``````  & 0 0 0 1 0 1 1 0 1 0
3 5 6 8
``````

Ah ha – “what are the offsets of the 1s?”

``````  x:10?!1000    / draw 10 random numbers 0 to 999
x             / print them
379 998 594 106 191 686 123 845 495 700
x < 500       / what values are less than 500
1 0 0 1 1 0 1 0 1 0
x[&x<500]     / slice x by indices where x is less than 500
379 106 191 123 495
``````

So it combines with a conditional to become a sort of SELECT, but it also combines with other operators in a predictable way, and the implementation is straightforward.

1. 1

Thank you! I was stumped as to what the `where` usage of `&` is for. This is a great explanation.