Well, ⊥
is quite simple. In a way, it is a fancy +.×
It just gives the given "digits" weights, and sums the result.
The weights being determined from the reverse cumulative product of the left argument. (And there's some transposing going on too.)
⊤
is much more complex, computationally speaking, but not really conceptually, where it is basically the inverse operation.
I think the best way to explain it, is to show how ⊤
constructs its result. As a simple example, let's take:
0 7 24 60⊤12345
1 1 13 45
The 0 7 24 60
here represents a number system with 60 of the basic units in the next larger unit, 24 of those larger units in the next larger, etc.
It could e.g. be 60 minutes in an hour, 24 hours in a day, and 7 days in a week.
The 0 means that there are no larger units, and we'll keep stacking large value multiple in that position no matter how big the "pile" gets.
Compare this to making cash change. There's nothing larger than a $500 unit, so even if we have to pay a million, we'll have to use lots of $500s.
OK. What are our weights?
⌽×\⌽1,⍨1↓0 7 24 60
10080 1440 60 1
That is, there's 1 minute in a minute, 60 minutes in an hour, 1440 minutes in a day, and 10080 minutes in a week.
We can check the result that ⊤
gave us, by using these weights:
1 1 13 45+.×⌽×\⌽1,⍨1↓0 7 24 60
12345
How did ⊤
get the result then?
Let's do it step-by-step. We build our result from the right.
The first unit rolls over at 60, so we can find how many of the smallest units (here, minutes) we need to get the exact total value by applying division remainder:
There's our right-most "digit". Let's put that aside in our result. How many minutes are left?
The next unit (the hours) consist roll over at 24 hours of 60 minutes each.
So any multiple of 24 hours will be days instead. We only want the remainder of 24-hour-periods, that is, 24×60 minutes, to be counted in hours:
This is how many minutes we want counted as hours. How many hours is that, though?
Hey, there's the second-from-right element of our result. Let's prepend it to get a preliminary result of 13 45
So we've used 780 minutes this time around. How much do we have left (which will be counted in days and maybe weeks)?
Next up are days, which we'll use to fill until we have a value that can be counted in whole weeks.
A week, of course, being how many minutes?
So we need the division remainder when divided by that.
That's how many days (stated in minutes) we have. How many actual days does that add up to?
(24×60)÷⍨(7×24×60)|11520
1
Well, that's the next value in our result, giving us 1 13 45
. And left is how much?
Which you might recognise as a single week (expressed in minutes), i.e. we get another 1
in our result: 1 1 13 45
@all How was that? Still alive?