« first day (1722 days earlier)      last day (935 days later) » 

12:46 AM
in The Nineteenth Byte, 35 mins ago, by DLosc
Welcome to the fourth Learn You A Lang For Great Good event! Today's language is BQN, a recent addition to the APL family. For this event, feel free to ask about BQN, post CMCs to solve in BQN, and anything else related to the language. You can run BQN code online here.
Head over to TNB if you'd like to discuss BQN
 
 
3 hours later…
3:44 AM
@Marshall See the above! We have a bimonthly event in the main TNB chat room where we teach and learn a new lang. Today's featured language is BQN, and it'd be great to have you over. I think people would appreciate help learning it too; if you want to give a first lesson there you'll have an audience!
Otherwise maybe you'd like to hop on over, @Adám?
Anyway, I prob won't be on unfortunately, but just wanted to do the appropriate pinging to spread the message :)
 
 
1 hour later…
5:08 AM
Does it matter whether I write f¨⍨ or f⍨¨? For example, I found this code from APLcart for drawing a histogram: ↑'⎕'⍴¨⍨⌊ but ↑'⎕'⍴⍨¨⌊ also works.
I've noticed that if I think of ⍨ as the passive voice and read each symbol from left to right, f⍨¨ seems to translate more readily into English:
3⍴'⎕' (3 reshape quad)
'⎕'⍴⍨3 (quad reshaped by 3)
'⎕'⍴⍨¨1 2 3 (quad reshaped by each of 1 2 3)
 
5:36 AM
Well, you just find the commutative property of these operators! @rabbitgrowth
 
Sorry if it's obvious, I found it a bit surprising that they do the same thing
Should I prefer one or the other?
 
if you aim for performance, ¨⍨ is better because it only copy the argument once
while ⍨¨ copies each cell, which would suck when the argument is a large array.
However I do not oppose to sacrifice performance a little for readability.
 
6:12 AM
@danielvictordev Hi there. Interested in APL?
@rabbitgrowth It used to be like LdBeth describes, but the interpreter now understands that they are equivalent, so you can write either with no performance penalty.
 
@Adám Yes. Currently going through the Mastering Dyalog APL book.
 
Cool. Are you aware of mastering.dyalog.com?
 
@Adám I was not aware of this. I'll give it a go.
 
6:28 AM
@danielvictordev You might also find interesting things at apl.wiki/Learning_resources.
 
6:49 AM
I'm not sure I understand the "copying the argument" part - are X and Y in X f⍨ Y copied so that it becomes Y f X?
 
7:29 AM
Has there been any work on automatically differentiable Dyalog or APL generally?
 
@rabbitgrowth No, not really, but swapping the arguments will have some overhead.
@Amana You mean mathematical differentiation of numeric functions?
 
@Adám Yep! The basis of a lot of machine learning (not just neural nets, but probabilistic programming) is automatic differentiation of code
 
Iverson wrote some code for that. It was then built into J, but lately removed and put back into a library.
@Amana Elementary Analysis – now to find that somewhere (other than at the Dyalog office…)
 
@Adám I should have guessed J! Thanks
 
Relevant paper (requires ACM access)
 
7:49 AM
Ah, on a scan look like it doesn't do symbolic differentiation. Alas
 
@Amana "it"?
 
@Adám The Iverson paper
 
J did have symbolic derivative built-in
 
Which means that now you can easily look at the J code.
 
If you have the syntax tree of a function, it isn't too hard to transform it into its derivative using the ordinary rules anyway
 
8:02 AM
Right, I was thinking that was a nice thing about APL
 
 
2 hours later…
9:50 AM
0
Q: Unexpected value of expression involving assignment

August KarlstromI saw this logic and wonder why the result is one rather than zero: P ← 1 1 0 Q ← 0 0 1 ∨/ P ∧← Q 1 On the other hand the following results in zero: P ← 1 1 0 Q ← 0 0 1 ∨/ P ← P ∧ Q 0 I'm using Dyalog APL 16.

 
 
2 hours later…
11:35 AM
@Bubbler But APL doesn't really have a formal way to represent syntax tress, no?
 
11:59 AM
Any APL with nested array support can have one. J's trains have such representation, which can be manipulated with a J program
 
Well sure, but then all languages can have that.
Does J's parser generate this form and provides a mapping between the source and AST representations?
 
 
1 hour later…
1:22 PM
can i somehow precompute some stuff from a dfn while keeping it local?
say that i have some expression that doesn't depend on the dfn arguments, it's a waste to recalculate it each time
i don't want to put it in the outer scope because it'd pollute the namespace there
 
you could pass it as an operand maybe
 
the constant data i have is around 5 fairly complex expressions that yield a fairly big lookup table
 
you could wrap that in a dfn too.. so ({stuff}⍬) {mydfn} and then it's an operand
but easiest solution is probably just to do it in the outer scope
 
1:39 PM
what if i did (⎕ns'')∘{...} and referred to ⍺.something inside
 
I can see three obvious approaches:
∘ F←(data array)∘{… ⍺ …}
∘ F←(data array){… ⍺⍺ …}
∘ F←(data namespace).{… names …}
 
or write a tacit function
 
i don't think i could turn a 25 line monster into a tacit function :P
 
The first two of my approaches are certainly tacit.
@KamilaSzewczyk That's a special case of my first approach.
Good SO question, btw.
 
I was assuming the function was dyadic bc of 'arguments'
 
1:43 PM
Good point. The the last two approaches remain, of which the first one is yours.
 
yeah, using a namespace is clever didn't think of that
 
F←(⎕NS⍬)∘⍎ is a fun little function.
 
"fix into a namespace?"
 
all of these solutions suck so i'll probably just recalculate this all each and every time
      cmpx'cvte¨vec' 'cvte2¨vec'
  cvte¨vec  → 3.8E0  |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
* cvte2¨vec → 7.3E0  | +92% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
where vec←⍳10000
it's not too expensive
 
4 seconds or so is a big difference
can you share the code out of interest?
 
1:58 PM
Referencing variables from other namespaces can deactivate some optimizations
 
@KamilaSzewczyk Why?
 
@LdBeth i was worried about this
and there is just no elegant solution for this problem
 
can you post the code anyway? :P
 
you have to pre-initialise these static variables which means either holding a public namespace with these which doesn't alleviate the problem too much, or having special code that checks the name class of a dummy variable in a namespace to decide whether you should initialise the variables now.
 
or just do it in the outer scope? what's so bad about that
 
2:02 PM
but it's not so simple, the dfn will return after the guard, so you have to recurse somehow with the new namespace contents. and it becomes messier and messier, and you have to put the initialisations in a dfn
@rak1507 there's a bunch of variables called keys, ord, cs, etc... - they might clash with something
limiting your variables scope to the smallest possible is like, programming 101
 
use a namespace then? that's what they're for
 
Put them in a namespace.
 
@rak1507 it's related a bit to my code guessing entry
 
oh right
 
i can show you the code after sunday
it sucks because i hacked it together in uni cafeteria within 30 minutes but i'm a bit proud of what it accomplishes
(well it's actually near the campus but whatever)
 
 
5 hours later…
7:28 PM
@Bubbler Looks like its partial derivative is numeric rather than symbolic, so not so useful for ML models :-(
 

« first day (1722 days earlier)      last day (935 days later) »