« first day (1422 days earlier)      last day (1233 days later) » 
02:00 - 17:0017:00 - 00:00

2:39 AM
@Marshall wow, three characters
 
 
4 hours later…
6:40 AM
I thank the gods for the existence of
 
 
2 hours later…
ngn
8:13 AM
@Razetime lol :) the gods wouldn't do it this way, though. ⌺ is too each-y.
 
8:29 AM
well the gods can visualize tesseract math so idk
 
4
Q: Ken Iverson’s Favourite APL Expression?

Adám Ken Iverson, 1920–2020 Let's implement his favourite expression: Given a row of Pascal's triangle, compute the next row. This can for example be computed by taking the input padded with a zero on the left, and the input padded with a zero on the right, and then adding the two element...

 
ngn
9:30 AM
@Razetime "gods" in the context of array languages usually refers to those who are so good at q, they don't need to read the "for mortals" book
@Feeds @Adám this might be the only challenge that starts with its own answer :)
 
@ngn ;-) But in all seriousness, lots of challenges use non-golfed code to help specify the task, and the snippet (not a valid answer, since it is neither a function, nor a full program) is obviously not golfed.
 
For more seriousness, most of the challenges having a sample code put it at the end, not at the beginning
 
10:10 AM
How can I center (in leading axis) an array (or scalar) a of rank n in an array b of rank n+1? So if a is 5 and b is 0 0 0 0 0 → 0 0 5 0 0. Or if a is 1 2 3 and b is 3 3⍴0 → 3 3⍴0 0 0 1 2 3 0 0 0. Or another way to think of it is to raise rank and pad.
 
@xpqz You could copy the bigger array, then modify it.
 
This kind of works: a@1⊢((1+⍴⍴a)⍴⍴a)⍴0 at least for some cases.
 
10:53 AM
Today's AoC is a bit of an APL party trick.
 
very much so
 
@xpqz Will b always have an odd leading axis length? And if not, then what to do in that case?
 
@Adám yes.
(always odd)
 
@xpqz a@(⌈2÷⍨≢b)⊢b
 
Nice.
 
11:12 AM
AoC Day 17 -- Game of Life at ranks 3 and 4: gist.github.com/xpqz/e7705280f88b226471bc5df453153093
 
ngn
@xpqz is b always zeroes?
 
@ngn Yes. Basically: center in bigger empty array with rank n+1.
 
Oh. So why not take b's length instead?
 
ngn
or half of it?
 
@ngn Rounded up?
 
ngn
11:18 AM
@Adám down would be more convenient, i think
 
With l←≢b: (⌈l÷2)⊖↑l↑⊂a
With h←⌊l÷2: ↑(-h¯1h)⍀⊂a or with instead of
 
I created b, found the non-zero locations ⍸a and added half, and pre-pended half to the list of coordinates, sort of big[half,¨¯1+half+⍸a]←1. I'll try your suggestions now.
My case had a being boolean, which helped.
Ugly, but reasonably effective.
 
ngn
@xpqz presumably you want to pad all axes, not just the first?
 
^ that pads two axes (I think).
 
ngn
@xpqz i'm asking in general. if you want to pad a from all sides with n zeroes: (-n+n+⍴a)↑(n+⍴a)↑a (it can be golfed)
someone should invent a do-for-all-axes operator :)
 
11:34 AM
I've suggested that before.
 
ngn
@Adám i'm sure. it's the first idea that comes to mind when you see how ⌽'s ⍺ is designed.
you can do 1 1 1↑ and 1 1 1↓ and 1 1 1⌷ for 3d arrays but 1 1 1⌽ does something unexpected
 
@ngn Yeah, J fixed that, but there are other things you could do over multiple axes, e.g. 0⍪
 
ngn
@Adám right, though i wouldn't expect 0 0 0⍪ to pad all axes
 
@Konrad'Unrooted'Klawikowski Hi. Interested in APL?
Author wants to see an APL answer:
11
Q: Iterate over the neighborhood of a string

AnushInput A string S of length between 2 and 30. The only letters in the string will be a or b. Output All strings within Levenshtein distance 2 of S. You must output all the strings without duplicates but in any order you like. Example If S = aaa then the output would be (in any order): aa abab ab a...

 
@ngn Yes, that puzzled me this morning.
@ngn I shall make a note of that -- I've wanted something like that more than once.
 
12:04 PM
@Adám Yes, I am interested in APL, one of my friend talks about it non-stop And I want to learn it in 2021
Btw, any good resources where to start?
 
I'll be happy to give you a personalised intro. Right now even, if you want. But otherwise, look at APL Wiki's list.
 
I'd love to have that personalised intro if that's not a problem for you
 
@Konrad'Unrooted'Klawikowski For sure. I took the freedom of looking briefly at your website. You're functional programmer, interested in mathematics. Does that mean that you're comfortable with mathematics up to and including linear algebra?
 
Yep, I'm fine with those kind of stuff, I'm on extended math and extended physics profile in my High School
 
12:19 PM
Perfect. Now, because you've already done some programming (even if functional) we need to start with you discarding the notion that APL is a programming language (despite the initialism).
APL was invented by a mathematician (who loved matrices…) who intended a better alternative to traditional mathematical notation (TMN).
(Coincidentally, he would have turned 100 today, had he still been alive.)
So, APL doesn't try to be like other programming language. Instead, takes the best from TMN but generalises and harmonises concepts to yield a more consistent, and therefore machine-executable, notation.
We use × and ÷ (not * and /) for multiplication and division, just like it is taught to kids in school (well, in America, at least).
But APL is also array-oriented. You don't need to specify a loop to add one number to each element of a list: 1+(10,20,30) works.
@Konrad'Unrooted'Klawikowski Can you guess what (1,2,3)+(10,20,30) does?
 
It adds 1 to 10, 2 to 20 and 3 to 30...? Tho it's just a pure guess
Or 1+2+3 to every element?
 
That's right. Oh, and btw, the parentheses and commas are not needed (though it will work with them): ⋄ 1 2 3 + 10 20 30
 
@Adám 11 22 33
 
You can experiment via the chat bot by using a leading ⋄ in a back-ticked code phrase.
 
today's AOC is so easy in APL, it's quite funny
 
12:29 PM
Thanks, gonna try it
 
@rak1507 Someone should add an AoC page to APL Wiki, with links to people's solutions.
 
I also do think I can come and listen to that online egent today
 
I think ngn is collating sample solutions for each day
 
@Konrad'Unrooted'Klawikowski This might help you input APL characters.
 
@Konrad'Unrooted'Klawikowski I recognise your name and website but I can't put my finger on where from, this is very frustrating...
 
12:32 PM
@Adám thanks, gonna take a look
 
One of the things APL generalises compared to TMN is the position of symbols. TMN is all over the place… prefix: –a, suffix: a!, omnifix:|a|, superscript: a², none: ab, etc.
 
Now I had a thought about making Touch Bar app to input APL characters, that would be pretty cool
 
APL takes the usage from – and applies it universally: Two-argument functions are between their arguments, while one-argument functions are on the left of their arguments.
@Konrad'Unrooted'Klawikowski Yeah, I've suggested that too.
So factorial is !a and absolute value is |a
 
@rak1507 hm, maybe from one Discord? I'm @KamilaSzewczyk friend, maybe we do share some servers or something, I'm not very active, but maybe you've seen me somewhere there
@Adám got it, noted
Oh man this looks so cool
 
after a brief stalking session I think I have seen one of your tweets before
 
12:35 PM
APL has a rather large vocabulary of symbols (we call them primitive functions ― operators are something else, that we'll get to soon), so having a precedence order like TMN's × before + etc. wouldn't be reasonable.
Instead, we generalise the rule from repeated exponentiation ― ₂3⁴ is ₂(3⁴) ― i.e. right-to-left.
 
@rak1507 maybe because I took part in Haskell Love conference and I tweeted about it? dunno tbh
 
Another way to look at this is f(g(h(x))) which also evaluates from the right. We allow omitting the parens: f g h x
 
parens are just a cosmetic thing?
 
Here, yes.
We also allow each function to take an additional argument on it's left: a f b g c h x is a f (b g (c h x))
This means that 2 × 3 + 1 is 8, not 7. Do you understand why?
 
because it's calculated right to left?
 
12:47 PM
Yes, 2 × (3 + 1). It takes some getting used to, and you'll make mistakes in the beginning. But then it becomes natural.
 
everything is calculated from right to left in APL?
in equations like that I mean
 
Yes. Btw, this is much like in English:
> Look at the crashed red car
The first thing you have to evaluate is "car", then you can specify that it is "red", and "crashed". Only finally, can you "look" at it. The sentence cannot be understood from the left!
So APL (like English) is written from the left and evaluated from the right. It can often be read both ways for various effects.
 
Let's reach you another function: (Greek Iota). It takes generates Indices:
⋄ ⍳ 10
 
@Adám 1 2 3 4 5 6 7 8 9 10
 
12:55 PM
@Konrad'Unrooted'Klawikowski How would you generate the first 10 even indices, i.e. from 2 to 20?
 
maybe Iota 20 and then check if numbers are even and list just them?
 
Can you think of an arithmetic approach?
 
in Haskell, I would make a list of n, then I'd check if `mod` 2 == 0, if True, add it to list and then print out that list, or something like that
dunno about arithmetic approach tbh, I'd say something around the same, to check if dividing by 2 does produce natural number or something
 
Hello
 
(dunno if this is called like that in English, we call it like that here, I hope it's the same, and by natural, I mean numbers that don't have 'something.other_something' form)
 
1:01 PM
how would you do it in haskell with a list comprehension without using mod?
 
@Konrad'Unrooted'Klawikowski Think about how to map 1 2 3 4 5 6 7 8 9 102 4 6 8 10 12 14 16 18 20. What is the relationship, i.e. the mapping function?
 
hm, list comprehension
 
well map would work too
 
[x | x <- nums, even x, x <= 20] to check if it's even, I think this should work to list all even numbers not greater than 20
@Adám something as I said in Haskell? or am I not even close? lol
 
@Konrad'Unrooted'Klawikowski Yes, by what is the mathematical relationship that transforms 1→2, 2→4, 3→6, etc. until 10→20?
 
1:10 PM
does → do *2 or it goes to the closest even number in your message?
 
3→6 so that's a doubling.
 
got it, first thoughts always the best haha
 
The reason I'm drilling this, is because I want you to get used to the concept of working on whole arrays, rather than their elements. So, now, can you make the bot print those even numbers from 2…20?
 
gonna try
⋄ ⍳ 2...20
 
@Konrad'Unrooted'Klawikowski SYNTAX ERROR
 
Remember how to generate just plain numbers 1…10?
 
@Konrad'Unrooted'Klawikowski 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 
@Konrad'Unrooted'Klawikowski OK, but note that there are only 10 even numbers in the range we're looking for, not 20.
 
yeah yeah
how do I tell it to use that → as a x2?
in a specific range I mean
 
1:19 PM
You don't. Instead, take the result from and mathematically transform it.
 
⋄ ⍳ 1→2, 20
 
@Konrad'Unrooted'Klawikowski Illegal code
 
waaait
Iota does map all numbers not greater than specified?
 
how would you do 2 times 3
 
just 3→6 I think
 
1:23 PM
@Konrad'Unrooted'Klawikowski I was only using → to illustrate the transformation. Multiplication uses ×
 
Ok, that makes sense, sorry, my brain is kinda burning after 4h of extended physics today
Then 3×2 obviously
 
OK, so how if a list is called a how do you double the value of a?
 
2×a
Iota 2×10 is the answer for that question before?
 
Almost. Remember the order of execution.
 
1:27 PM
Almost. Remember the position of a one-argument function relative to its argument, being such a one-argument function.
 
@Razetime Good. I'll polish the formatting a bit.
 
thanks
 
(2×10) ⍳? Just the parens? I have No other ideas
 
well you know how to generate the list from 1 to 10
 
1:29 PM
try running your answer
 
⋄ (2×10) ⍳
 
@Konrad'Unrooted'Klawikowski SYNTAX ERROR
 
Hmm
I really do have no other idea for that tbh
 
@Konrad'Unrooted'Klawikowski Try backing up one step for a moment. Just generate indices 1…10.
 
1:32 PM
@Konrad'Unrooted'Klawikowski 1 2 3 4 5 6 7 8 9 10
 
Waaaait
⋄ ⍳ (10×2)
 
@Konrad'Unrooted'Klawikowski 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 
Thonk
⋄ ⍳ 10 ×2
 
@Konrad'Unrooted'Klawikowski 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 
1:34 PM
@Konrad'Unrooted'Klawikowski RANK ERROR
 
in APL you can do things to entire arrays without using map or something, so 1+1 2 3 is the equivalent of map(+1)[1, 2, 3] in haskell
maybe that helps
 
@Konrad'Unrooted'Klawikowski Slow down. Think about how you multiply in TMN.
 
Wait, that kinda helped
 
9 mins ago, by Konrad 'Unrooted' Klawikowski
2×a
 
⋄ ⍳ (×2)(10)
 
1:35 PM
@Konrad'Unrooted'Klawikowski 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10
 
ok maybe that didn't help sorry haha
 
@Konrad'Unrooted'Klawikowski now do that, but using APL syntax
 
You got ⍳ 10 and 2 × a right, so just combine those, substituting a with ⍳ 10
 
⋄ (×2) ⍳ (10)
 
1:36 PM
@Konrad'Unrooted'Klawikowski RANK ERROR
 
APL parses from right to left, but remember: it doesn't read from right to left.
 
That right to left calculation kinda messed up in my head
 
OK, let's take a detour…
If a and b are numbers, how would you add a to the negation of b? You can answer in either APL or TMN.
 
⋄ ⍳ 10 (×2)
 
@Konrad'Unrooted'Klawikowski 0x0.st/iFIl.txt
 
1:39 PM
you're passing an array to
you need to pass a scalar
 
@Razetime Hold your horses, you're using as-of-yet undefined terminology.
 
Scalar as in physics?
 
⍳10 is correct, leave that, now you have to multiply it by 2
 
@Konrad'Unrooted'Klawikowski Try answering my detour question first.
 
Negation is like, in English anybody, anyone, anything etc...? I don't know English names for everything yet
 
1:42 PM
minus of the number
 
@Konrad'Unrooted'Klawikowski Oh, negation means flipping the sign; positive becomes negative, and negative becomes positive.
 
Ah, thanks
A+(-1)(b)
Because (-1) flips the sign from positive to negative and negative to positive
 
True, but can you not write that in a simpler manner?
 
And also × between (-1) and (b) I think
(a) + (-b)?
 
Yes, exactly. That'll work in both TMN and APL. (Btw, you don't need parens there in either.)
@Konrad'Unrooted'Klawikowski Now, try to modify that expression step by step. What if you didn't want to add a to -b but instead wanted to multiply?
 
1:45 PM
a×-b
And now I need the parens sorry
Or is it again å cosmetic thing?
 
Perfect. (And no, you don't need parens.) What if you didn't want to negate b but rather wanted the indices until b, using APL?
 
@Konrad'Unrooted'Klawikowski it's correct
 
Yes!
 
go ahead, run it
 
1:47 PM
So
2×iota10?
 
yay
 
@Konrad'Unrooted'Klawikowski 2 4 6 8 10 12 14 16 18 20
 
Bravo!
 
1:48 PM
Btw, you can use parens to govern the order of execution in APL, just like in TMN.
 
So it's not just cosmetical?
Seems logical
 
any method of evaluation needs brackets
 
No, only in some cases, where you parenthesise a value that is already being evaluated like that.
@Razetime No, not (Reverse) Polish Notation.
 
ah yes
are we going for product of list now?
 
@Konrad'Unrooted'Klawikowski Now, can you think of how you could generate the first 10 odd numbers 1, 3, 5, … 19?
 
1:50 PM
@Razetime You can link to my top AoC repo: github.com/xpqz/AoCDyalog -- every year since 2015 in Dyalog
 
up to 21, no?
 
@RewCie Please use the sandbox.
 
sorry...
 
But, since you're here; interested in APL?
 
Just there watching.... maybe I find something interesting to do with it.
 
1:52 PM
No worries.
 
@RewCie Try Advent of Code :)
 
@xpqz dun
 
What's Advent of Code?
 
⋄ 2÷2×⍳ 20
 
1:53 PM
@Konrad 'Unrooted' Klawikowski
1 0.5 0.3333333333 0.25 0.2 0.1666666667 0.1428571429 0.125 0.1111111111 0.1
      0.09090909091 0.08333333333 0.07692307692 0.07142857143 0.06666666667
      0.0625 0.05882352941 0.05555555556 0.05263157895 0.05
 
Aug 11 at 15:20, by Adám
@Razetime Welcome to. We're in the middle of an APL lesson, but feel free to hang around.
 
@xpqz Looks beautiful to me... :)
 
No wait
To get an Odd you just +1 to every even
⋄ 1+2×⍳ 10
 
@Konrad'Unrooted'Klawikowski 3 5 7 9 11 13 15 17 19 21
 
1:54 PM
Almost there, you're off by 2.
 
are you going to mention ⍨
 
@Konrad'Unrooted'Klawikowski 3 5 7 9 11 13 15 17 19
 
@rak1507 three hyphens
 
And why does it miss 1?
 
1:55 PM
@Konrad'Unrooted'Klawikowski what does 2×⍳10 exaluate to?
 
@rak1507 You guys :-D Slow down, we've not even introduced operators yet! I know it is all very obvious and easy for you, but it is very alien for a newcomer within their first two hours.
 
@Razetime it gives even numbers so I'm +1 to get an odd
 
yes,
 
Yes.
 
1:57 PM
exactly
 
⋄ 1-2×⍳ 10
 
@Konrad'Unrooted'Klawikowski ¯1 ¯3 ¯5 ¯7 ¯9 ¯11 ¯13 ¯15 ¯17 ¯19
 
Lol what happened
 
Hold on, how do you subtract 1 from a in TMN?
 
(What's TMN, by the way?)
 
@Razetime Traditional Mathematical Notation.
 
If that's what you're asking
 
@Konrad'Unrooted'Klawikowski OK. It is the same in APL.
 
⋄ - 1 2×⍳ 10
 
@Konrad'Unrooted'Klawikowski LENGTH ERROR
 
1:59 PM
@Konrad'Unrooted'Klawikowski Instead of subtracting 1, you subtracted from 1
 
Wow! This APL is so elegant and intuitive!
 
⋄ -1 2×⍳ 10
 
@Konrad'Unrooted'Klawikowski LENGTH ERROR
 
Lol what happened
 
1:59 PM
@Konrad'Unrooted'Klawikowski The minus sign needs to go between its arguments, just like all 2-argument functions do.
 
⋄ 1- 2×⍳ 10
 
@Konrad'Unrooted'Klawikowski ¯1 ¯3 ¯5 ¯7 ¯9 ¯11 ¯13 ¯15 ¯17 ¯19
 
Why does it have levitating floors
 
¯ is used for negative numbers in APL to distinguish from -
 
Those indicate negative numbers. We use a high minus to distinguish from the subtraction/negation function.
 
2:01 PM
Noted
⋄ ¯1×1+2×⍳ 10
 
@Konrad'Unrooted'Klawikowski ¯3 ¯5 ¯7 ¯9 ¯11 ¯13 ¯15 ¯17 ¯19 ¯21
 
Among other reasons, this avoids TMN's ambiguity in –3²; is it (–3)² or –(3²)?
 
@Konrad'Unrooted'Klawikowski Why do you have ×1+ there?
Oh, you're trying to multiply ¯1 and 1 before you add that to the even numbers?
You could just calculate ¯1×1 in your head, and use that value directly.
 
Since without ¯1 it gives me negative numbers, I thought about multiplying it by ¯1 to get positive numbers
 
2:03 PM
@Konrad'Unrooted'Klawikowski you did 1*-*2×⍳10 earlier, remember?
 
so do the same thing with that
 
@Konrad'Unrooted'Klawikowski Yes, that'd work with 1-2×⍳10 but is more complicated than necessary. Why not just subtract 1 from 2×⍳10 ?
 
⋄ 1-(2×⍳ 10)
 
@Konrad'Unrooted'Klawikowski ¯1 ¯3 ¯5 ¯7 ¯9 ¯11 ¯13 ¯15 ¯17 ¯19
 
2:05 PM
7 mins ago, by Konrad 'Unrooted' Klawikowski
a-1
 
⋄ (2×⍳ 10)-1
 
@Konrad'Unrooted'Klawikowski 1 3 5 7 9 11 13 15 17 19
 
Yippee!
OK, I think you now understand how this works.
 
oh look at the time it's ⍨ o'clock
 
2:07 PM
@rak1507 Nah, the minute arm is at /
 
I hope so I do understand lmao
 
Are you up for more, or are you exhausted?
 
I'll have to eat and drink something because I have more lessons at 4pm (Python lessons, sadly), but maybe in the evening I can come back for a while if that's not a problem, I also can try being there on that online event this evening
 
wish my school did python lessons instead of VB, it could be worse...
 
Cool. See you around. Just ping me if you want more, and as you can see, the others here are also eager to teach.
 
2:10 PM
Imagine
APL school lessons
 
@rak1507 I wish my school had done programming… Well, maybe not. I would have been annoyed by having to use non-APL languages.
 
Yeah, I think I can easily say that's this community is one of the most, if not the most open one for newcomers
 
@Razetime RikedyP and I started giving APL classes at schools right before the pandemic accelerated out of control.
 
@Adám Guess I'm moving to London, then
 
Maybe if I get my way and things calm down a bit I can see if that would be an option at my school at some point
 
2:14 PM
learning APL at school would have been waaay better than basic Java
 
Well, Python lessons in my schools are only for those who think about Matura Or Abitur (auf Deutsch) from IT, so for people who additionaly, to extended maths and extended physics have 'extended' IT added
 
sqa.org.uk/sqa/files_ccc/… if you think java is bad, take a look at the SQA reference language...
 
Iverson very much had teaching in mind.
@Bubbler @rak1507 Should I avoid using your real name on APL Wiki?
 
I personally don't mind but I don't see that much reason to include it
 
For linking to your AoC solutions.
 
2:25 PM
Sure then
 
Sure, use real name, or sure avoid that?
 
Use real name, I don't mind
 
@rak1507 Well, SQA Reference language isn't used in over a billion devices
and I highly doubt it's taught at school
 
it absolutely is taught at school
not to write but to read for exam purposes
 
oh pseudocode
 
2:33 PM
it's similar in purpose to pseudocode but it's standardised now so it's not even pseudocode really, weird stuff
 
huh
 
@rak1507 your pad function -- much better than mine. I'm stealing it...
 
Oh man. I swear I searched for every term (just not that).
 
I think I searched for 'pad with' or something
 
2:40 PM
 
hardcodes dimensions so would have to be different for both solutions
 
@xpqz Can you list the terms you searched for, so I can add them?
@user9047754 Hi avalloch. If you want to participate here, email me: adam@ with the same domain as www.dyalog.com
@Razetime OK, polished a bit, but there are lots more to add.
 
@Adám I think my problem was rather that I didn't think of it in those trerms (surround with scalar), but "center in larger".
 
@Adám wow that's a... whole lot
 
A lot of them are old or use APL for one or two answers
 
2:47 PM
eh I'll just get all of em
 
@xpqz OK, that should work now.
 
this is cool, anyone know who this is?
 
ok, I am not able to figure out the Github search API
 
@Razetime Why do you need it?
 
@Adám I wanna try getting the links for this query
 
2:58 PM
@Adám as you speak the language -- a good use for APL? fra.se/nyheter/nyheter/nyhetsarkiv/news/…
 
ngn
cmc (fastest code): neighbours sums (of the 3^n neighbours, including self) for an any-dimensional array. neighbours outside the array are treated as 0s.
 
@ngn So {{+/,⍵}⌺(3⍴⍨≢⍴⍵)⊢⍵}?
 
ngn
@Adám yes, but fast
@Adám 3⍴⍨≢⍴⍵ -> 3⊣¨⍴⍵
 
@ngn would your no-stencil-stencil trick on the ravel have made today's AoC faster? Although it was passably fast with stencil...
 
ngn
@xpqz i don't know which trick you mean, but today's input was so small, it doesn't matter. but the cmc should be fun :)
 
3:12 PM
@ngn That shouldn't matter. I guess it is as fast as can be, no?
 
ngn
@Adám no, that's just shorter and cuter :)
 
{+/,⍵} is special-cased by for odd neighbourhood sizes, I think.
 
ngn
@Adám afaict it has disastrous performance
 
Can you demonstrate that?
 
@ngn The best performance would be john scholes' life algorithm right
pad, rotate once in all directions and add everything up
 
ngn
3:15 PM
@Razetime not necessarily
 
It uses nested arrays. Upping the rank would be faster.
 
that's the only other thing I can think of
 
I have this strange idea of working through and reviewing several older texts on APL. Partly the idea is to show how stable the underlying fundamentals of the language have been over time. Another is to provide updated examples from some of these texts to use trains/rank operator/etc. Is that something others here would be interested in reading?
 
@Razetime You don't want to do 3*n rotations, so you'd want to decompose it to work on a smaller number of axes at a time. One at a time gives you the smallest number of rotations to perform, but if boolean rotation is 8x faster than integer rotation then you'd probably prefer to do to axes together first.
 
@ab5tract Certainly.
@xpqz That's so easy. Just look at letter frequencies.
 
3:28 PM
@Adám Cool! Sometimes a little external motivation is helpful :) .. At least two of these books have appendices with instructions about using acoustic couplers. It makes me nostalgic for a time during which I didn't live. So there is a certain extent of general computing history involved too.
 
ngn
@Adám i got -22% with {n←≢⍴⍵⋄+/((n⍴3),3*n)⍴⊢⌺(n⍴3)⊢⍵}, testing with cmpx on ?30 70 50⍴2*53. but there's a smarter algorithm.
 
@ngn Maybe the optimisation is only for 3D. Can you check?
 
ngn
@Adám but this is 3d
 
Sorry, I meant 2D
 
Starting in chronological order, I will begin with 1970's APL Programming and Computer Techniques by Harry Katzan, Jr.
 
ngn
3:38 PM
@Adám yes, stencil is much faster for 2d
 
@Razetime Okay, before I forget about this, the CMC was to find ((⍵[0]≤⍺)∧(⍺<⍵[1]))∨((⍵[2]≤⍺)∧(⍺<⍵[3])) for a vector and number (can swap the argument order), and two APL solutions are 2|⍸ and ≠/≤. Here's a translated BQN example.
 
ngn
@Marshall nice, i had only 2|⍸
 
ngn
4:00 PM
@ngn oops.. that's wrong
the solution was wrong, it should have been {n←≢⍴⍵⋄+/((⍴⍵),3*n)⍴⊢⌺(n⍴3)⊢⍵}. the conclusion about 2d vs 3d stencils is still correct.
 
4:19 PM
@Marshall oh nice
 
4:40 PM
another day, another question about implementing a bqn runtime (i should have some time over xmas break to put in some work).

so, as I understand it, in the reference bqn implementation, environments can be nested. get/1, ge/2, and set/2 work on references to environments/slots in this nested structure. what I think i need to do, is flatten the environments into a key-value structure (the "heap" for lack of a better term), where the key is a unique reference, and the value is the environment itself (array of slots & parent environment reference).
 
@cannadayr pretty much everywhere environments are you will need to use an index in the heap.
 
ngn
4:55 PM
why is 3+/ so slow? i can beat it with apl code :)
 
02:00 - 17:0017:00 - 00:00

« first day (1422 days earlier)      last day (1233 days later) »