« first day (1120 days earlier)      last day (1524 days later) » 

7:18 AM
@Adám dfns.segs is missing from the contents page.
 
7:31 AM
@Bubbler We're working on moving the dfns workspace to GitHub, making it easy to fix such things and contributing in general.
 
7:59 AM
CMC: This but you must generate a nested result so boxing displays it as the first example.
 
 
3 hours later…
10:44 AM
Given a matrix like
⋄⍉20 2 ⍴ ⍳5
 
@xpqz
1 3 5 2 4 1 3 5 2 4 1 3 5 2 4 1 3 5 2 4
2 4 1 3 5 2 4 1 3 5 2 4 1 3 5 2 4 1 3 5
 
Is there a neat way to turn that into a vector where each element is a vector consisting of the corresponding elemens from row 0 and 1 in the matrix, ie
⋄(0 1) (2 3) (4 0) ⍝ etc
 
@xpqz
┌───┬───┬───┐
│0 1│2 3│4 0│
└───┴───┴───┘
 
⋄ ⎕IO←0 ⋄ ,⌿⍉20 2 ⍴ ⍳5
 
@Adám
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│0 1│2 3│4 0│1 2│3 4│0 1│2 3│4 0│1 2│3 4│0 1│2 3│4 0│1 2│3 4│0 1│2 3│4 0│1 2│3 4│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
 
10:48 AM
@xpqz Like this ^ ?
 
:) yes, just like that!
What about if I have just a vector of an even number of integers -- can I turn that into a vector of pairs?
 
11:05 AM
⋄⎕io←0⋄2,/20 ⍴ ⍳5
 
@SamThompson
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│0 1│1 2│2 3│3 4│4 0│0 1│1 2│2 3│3 4│4 0│0 1│1 2│2 3│3 4│4 0│0 1│1 2│2 3│3 4│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
 
like this?
Ah that's not right
 
⎕←{⊂⍵}⌺(⍪2 2)⊢⍳10
 
@JamesHeslip
┌───┬───┬───┬───┬────┐
│1 2│3 4│5 6│7 8│9 10│
└───┴───┴───┴───┴────┘
 
There's a new glyph for me: ⌺
 
11:11 AM
@xpqz does that achieve what you're after? Using the stencil operator, we can group with the input into a window size of two, jumping two each time. Similarly we could up the window size, or jump if you wanted triplets, etc.
 
That's exactly what I wanted to achieve, thanks. I will read the docs on ⌺ with interest.
 
@xpqz There's also:
⎕←↓20 2 ⍴ ⍳5
 
@Adám
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│1 2│3 4│5 1│2 3│4 5│1 2│3 4│5 1│2 3│4 5│1 2│3 4│5 1│2 3│4 5│1 2│3 4│5 1│2 3│4 5│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
 
@xpqz And:
⎕←(20⍴2↑1)⊂20⍴⍳5
 
@Adám
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│1 2│3 4│5 1│2 3│4 5│1 2│3 4│5 1│2 3│4 5│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
 
11:23 AM
So a monadic ↓ "flattens" a matrix by 1 dimension?
 
@xpqz Yes, the down arrow symbolises decreasing rank (number of dimensions).
 
That's a useful trick to remember.
 
Correspondingly, will increase the rank (at expense of depth), if any additional depth is available.
 
12:20 PM
⎕←2{p←⍸S⍷⍨' ',A←c⊃⍨⊃⍒≢¨c←(S∊⎕A)⊆S←' ',⍵ ⋄ C←⍵⊂⍨1@({((≢S)>⍵)/⍵}p,p+≢A)⊢0⍴⍨≢⍵ ⋄ ⍺{0=⍺:⊂∊⍵ ⋄ ((⊂(¯1+⍺)∇ C)@(⍸A∘≡¨C))⍵}C}'GNU''s Not Unix'
 
@TessellatingHeckler
┌──────────────────────────────┬───────────┐
│┌────────────────┬───────────┐│'s Not Unix│
││┌──────────────┐│'s Not Unix││           │
│││GNU's Not Unix││           ││           │
││└──────────────┘│           ││           │
│└────────────────┴───────────┘│           │
└──────────────────────────────┴───────────┘
 
⎕←1{p←⍸S⍷⍨' ',A←c⊃⍨⊃⍒≢¨c←(S∊⎕A)⊆S←' ',⍵ ⋄ C←⍵⊂⍨1@({((≢S)>⍵)/⍵}p,p+≢A)⊢0⍴⍨≢⍵ ⋄ ⍺{0=⍺:⊂∊⍵ ⋄ ((⊂(¯1+⍺)∇ C)@(⍸A∘≡¨C))⍵}C}'YOPY Own Personal YOPY'
 
@TessellatingHeckler
┌────────────────────────┬──────────────┬────────────────────────┐
│┌──────────────────────┐│ Own Personal │┌──────────────────────┐│
││YOPY Own Personal YOPY││              ││YOPY Own Personal YOPY││
│└──────────────────────┘│              │└──────────────────────┘│
└────────────────────────┴──────────────┴────────────────────────┘
 
Yikes.
 
Not sure that hits every case, but it's far and away the closest I've come so far
also tio.run doesn't like ]boxing on?
 
12:23 PM
@TessellatingHeckler It runs a clean environment without bells a whistles, but you can look at how the bot does it. Alternatively, you can use dfns.disp
 
⎕←]boxing
 
@TessellatingHeckler
VALUE ERROR
      ⎕←]boxing
         ∧
 
#tio alias view
 
@Adám
Command Aliases:
]help -> #tio do apl-dyalog (⎕NS⍬).(enableSALT⊣⎕CY'salt')⋄⍎'⋄⍬',⍨⎕FX↑'⍙⍙' ':trap 0'('⎕SE.UCMD',''''{⍺,⍺,⍨⍵/⍨1+⍺=⍵}120↓2⊃⎕SRC⎕THIS)':else⋄⊃⎕DM⋄:end'⍝help -url "%args%"
⋄ -> #tio apl ⎕SE.d←{(1=≡⍺)∧⍬≡⍴⍺:⎕←⍺dft 0⋄⎕←disp⍺}⋄⎕SE.(⎕WS'Event' 'SessionPrint' 'd'⊣⎕CY'dfns')⋄⍎'⋄⍬',⍨⎕FX↑'⍙⍙' ':trap 0'(162↓2⊃⎕SRC⎕THIS)':else⋄↑'' ''@(⍳6)¨@{0 1 0}⎕DM⋄:end'⍝%args%
)tio -> #tio do apl-dyalog ⎕←'https://tio.run/##','\+' '='⎕R'@' ''base64 10↓¯8↓256|⊃⌽3(219⌶)¯128+256|128+(⎕UCS'apl-dyalog'),t,('UTF-8'⎕UCS 157↓2⊃⎕SRC⎕THIS),t←255 255⊣'base64'⎕CY'dfns'⍝%args%
 
@TessellatingHeckler Try it online! You can change disp to dsp or display or displayr or displays for various output styles.
 
12:34 PM
@Adám I'll have to come back to that later
Fixed
now it does "work", I can take the "yikes" :|
 
 
2 hours later…
3:03 PM
@JPeroutek Should be up now. We had changed server and failed to authenticate the new one. Oops.
 
@Adám I saw that, thank you for looking into it!
 
@Adám - My brain does strange things when I'm falling asleep. Last night, I think it came up with an APL-based game of inductive reasoning.
The game is played by any number of people greater than 1. One of them is the Master, the rest are Students. The Master devises, but does not explain to the players, a function, which takes parameters and returns a boolean, according to a rule - it must be deterministic.
Play commences with the Master giving up to five examples of valid input to the function, and the results of applying the function to the input. There should be both 1 and 0 outputs in the examples.
 
3:21 PM
@JeffZeitlin Ooh, that sounds fun.
 
The players take turns doing one of two things: (a) they provide inputs to the function, and get the output, or (b) they present the Master with inputs and a prediction of the output.
The players take turns doing one of two things: (a) they provide inputs to the function, and get the output, or (b) they present the Master with inputs and a prediction of the output.
If (b), the Master tells them whther their prediction was correct.
The objective is for teh Students to derive a function that returns the same result as the Master's function, for all inputs that are legal for the Master's function.
I haven't worked out scoring, but there should be some scoring to encourage predictions from th Students (but penalties for wrong predictions), and for Getting A Right Answer.
A harder variant might be to allow non-boolean output.
I could see that game being used in the teaching of APL, as a way of encouraging learners to think about how APL works, and what the various primitives do.
 
3:46 PM
@JeffZeitlin, sounds like fun
If you do develop something like this, let me know. We can always use more training resources for our apprentice APLers.
 
3:58 PM
@JeffZeitlin This sounds like lots of fun. We should have such sessions at our conferences. Or maybe scheduled events here… However, there has to be some limits to the complexity of the function. E.g. {⎕RL←⍵ 1⋄ 2|?1000} would be "hard" to crack.
 
Yes, that's an important detail. I also would be disinclined to allow functions that rely on ? (roll or deal) as they
aren't really deterministic without playing with Quad-RL
(What's the magic for getting the bot to give me the APL symbols to cutpaste? I don't have Dyalog on this computer...)
 
4:16 PM
@JamesHeslip - Modulo scoring rules, that's the game right there. Simple to describe, but the game has some serious depth, because APL does.
Hmmm... Not exactly a new idea, either... See Zendo.
/me scribbles a note to get Zendo.
 
4:46 PM
@JeffZeitlin You know you can always ask the bot with )about right?
 
@Adám - Forgot about )ABOUT; thanks. I think over the weekend I'll write the game up more formally, and work up some scoring rules. Once I've got that, do you have someplace I should send the resulting document?
 
@JeffZeitlin You could create an APL Wiki page for it. Mustn't there also be some limit to the function length or number of primitives? E.g.: ⌊-0.5⁴+0.2x³-1.2x²+0.1x⌋ mod 2 will be hard to guess:
⍞←{2|⌊+/0.1 ¯1.2 0.2 ¯0.5×⍵*⍳4}¨⍳30
 
@Adám 0 1 0 0 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 0 1 0 0 1 0 0 0 1 1
 
I think limits to the length/number of primitives is something that should be "tuned" to the group that's playing - for example, if you have a bunch of learners, you might want to limit to (say) five primitives and no operators other than reduction; with a highly-experienced group, you would want a higher limit with no restrictions except perhaps exclusion of ?.
And, naturally, the set of allowed primitives - and/or system functions - can be fine-tuned to force a focus on a particular concept, if you're using the game as a learning tool.
 
5:05 PM
@JeffZeitlin My main concern here is choosing which primitives to allow/ban. Something like would be impossible to break.
 
Hmmm... Yes, that would be an issue. The ultimate goal, though, isn't for the Students to derive the exact function that the Master created, just to derive a function that the Master can't disprove is correct (by providing an input set that produces different results for the two functions).
)about
 
@JeffZeitlin Evaluate one line of APL by prefixing it with . Use ⍞← instead for inline one-liner answers. Use ] to call user commands, including ]help ⍣ for help on a glyph etc. Do not use markdown, but fixed-width (4 initial spaces, Ctrl+K) is fine. Commands: )lb for language bar, )docs for full documentation, )ref for PDF reference card, )idioms for idiom list, )tio to create link or prefix code with f← for link to separated function assignment.
 
@JeffZeitlin ← +-×÷*⍟⌹○!? |⌈⌊⊥⊤⊣⊢ =≠≤<>≥≡≢ ∨∧⍲⍱ ↑↓⊂⊃⊆⌷⍋⍒ ⍳⍸∊⍷∪∩~ /\⌿⍀ ,⍪⍴⌽⊖⍉ ¨⍨⍣.∘⍤@ ⍞⎕⍠⌸⌺⌶⍎⍕ ⋄⍝→⍵⍺∇& ¯⍬∆⍙Install…
 
5:21 PM
As an example, if you're playing the version that doesn't require boolean results, and Master uses {⌊⍵} but Student comes up with {⍵-1|⍵}, that would be considered a success on the Student's part, unless either - or | is expressly prohibited in that particular session of the game.
 
In my attempts to learn apl I've managed to do day3 of advent of code. Baby steps :) github.com/xpqz/aoc-19/blob/master/day03.dyalog feedback most welcome.
 
5:37 PM
/me heads out for lunch and errands.
 
@xpqz It is good practice to write (d s)← rather than d s← as the former will error (outside dfns) if s is a function.
@xpqz Your intersects function splits and into twice as many pairs as needed. It won't affect the result (since you have ) but it is a bit wasteful. James' is neat.
@xpqz I recommend adopting a naming convention so the reader can distinguish between functions and variables. I can give you a few ideas if you want.
 
5:56 PM
Great feedback, thanks. I'm fumbling in the dark a bit when it comes to style -- I assume that production APL isn't "golfed to the max"?
Or maybe it is? I hear the k-crowd pride themselves in every byte saved.
Is there a dyalog style guide of sorts?
 
@xpqz No. My father, who was a great APLer, said the one should comment the APL code so it could be rewritten just from the comments. Use proper names for things. I like naming things so expressions read well, possibly only needing connection words like of to in etc.
 
6:11 PM
Can you show me what was wrong with my intersects dfn? I don't see it.
 
6:33 PM
@xpqz Not a public one, but I can tell you what our internal style guide says, and I can tell you my own version of it, and also my father's naming convention. I have also contemplated a convention for distinguishing types of operators.
 
Awesome :)
 
@xpqz You find reshape into two columns, but the number of rows only needs to be half the original length, not the full length, that is, (2÷⍨≢⍺) 2⍴⍺.
@user41805 @famous1622 Welcome to the Orchard. Interested in APL?
 
i'm kritixi lithos :P
 
@xpqz Dyalog internal guide says what we write should be well documented, perform efficiently, opt for clarity over cleverness (unless clever is faster, but then document cleverness!), inline assignments are OK within reason (code should be restartable!). Don't write excessive argument checking (reasonable and efficient checking is fine, not performance impeding checks) or have long one-liners.
@user41805 What happened‽
 
and yes i am still interested in apl
 
6:46 PM
:-D
 
@Adám i've been kritixi for too long, so i'm disassociating from that
 
@xpqz Dyalog continues: ⎕ML and ⎕IO should be 1 except judiciously and local ⎕IO←0. Set other sysvars when needed. Put :Fields at top of scripts, use named :Sections group entities like constructors. Class/namespace scripts should have a Version function giving 'name' 'major.minor.count' 'YYYY-MM-DD' and have comments. Use CamelCase for keywords and fully qualified :EndIf etc. (not :End).
@xpqz Dyalog naming conventions: variablesInDromedaryCase, GLOBALVARIABLESINALLCAPS, EverythingElseInCamelCase.
@xpqz Dyalog internal documentation through comments: block at top to describe purpose, dependencies, and for functions/operators, also: arguments/operands and result. Comment fields with purpose, valid value, and default value.
@xpqz Dyalog containers (namespaces, classes, workspaces…) should have a Describe function which returns a result text description, and workspaces should have ⎕LX←'Describe'
@xpqz My personal differences from this are: Everything that syntactically behaves as an array is dromedaryCase (this includes all objects and niladic functions). Monadic operators are _UnderscoredPrefixCamelCase and dyadic operators are _UnderscoreOmnifixCamelCase_. I avoid parens for order of execution, using them only for stranding and inline simple trains. Instead, I give intermediary values meaningful names.
 
7:08 PM
@Adám Maybe, I like trying to toy around with different languages. Been pretty busy though
 
@famous1622 I'd be happy to give you a little intro. Which languages do you know?
 
7:20 PM
@Adám thank you. I'll try to adopt some of these rules
 
@Adám
 
@famous1622 Yes?
 
"Formally" java and python, I've played with a good number of the traditional languages though
 
@famous1622 And what have you toyed with? Mainly Pyth?
 
Yeah, mainly pyth
Tried some Jelly and CJam but never anything I've been happy with to submit for code golf
 
7:26 PM
@famous1622 APL is cool because it stands a chance in golfing, while also being a real world production language. Oh, and it tends to be fun to write in too.
 
Yeah, that's what's kept it in the back of my mind, seems relatively to read too (compared to other languages in it's golfing "ballpark")
 
Yes. Especially if you like mathematical formulas. Can I ask you what your background is?
 
I'm a high school junior leaning heavily towards computer science, not much background past that :P
Unless I misinterpreted the question
 
No, you got it. And: no problem. One nice thing in APL is that it uses proper mathematical symbols like × for times and ÷ for division. Array comprehension fundamental:
⍞←2 × 1 2 3 4
 
@Adám 2 4 6 8
 
7:37 PM
Guessing I can't do something like:
⍞← 1 2 × 1 2 3 4
not sure what I'd expect it to do anyways
 
@famous1622 Right, you'd have to decide (and express) what you want. Also, the bot doesn't understand expressions inside messages. Make a separate message for it:
⍞← 1 2 × 1 2 3 4
 
@Adám LENGTH ERROR
 
Makes sense, and I'm guessing that length error means the 2 before × is an array too?
 
There are two arrays here 1 2 and 1 2 3 4. Spaces are all it takes to form an array in APL.
 
Oh, okay
 
7:42 PM
However, this works fine:
⍞←1 2 3 4 × 1 2 3 4
 
@Adám 1 4 9 16
 
APL was actually originally invented by a mathematician and mathematics teacher who got tired of the issues in traditional mathematical notation (TMN) and set out to create a better one. A couple of his ideas were adopted by mainstream mathematicians, but some of his disciples took his "better math" and made a linear version (not relying on sub- and superscripts, position, fonts, etc.) which became A Programming Language.
 
8:02 PM
⍞←2 2⍴1 0 0 1 ⌹ 2 1⍴1 2
 
@famous1622 LENGTH ERROR
 
@famous1622 is a normal function (not a declaration or prefix or anything) so you need parentheses:
⍞←(2 2⍴1 0 0 1) ⌹ 2 1⍴1 2
 
@Adám 0.2 0.4
 
Oh okay! Answer still seems off, but I probably just need to brush up on my matrix math
 
You may want to swap the arguments. That'd solve the equation system:
1a 0b = 1
0a 1b = 2
 
8:08 PM
Yeah, that's what I thought it'd do, although what is it doing with them the way they are now? if you don't mind me asking
 
@famous1622 It is finding a result R such that (2 1⍴1 2) +.× R becomes as close to 2 2⍴1 0 0 1 as possible, where +.× is matrix multiplication.
 
ah, so it's just multiplying by the inverse
 
Exactly. This way it is parallel how X÷Y is X×(1÷Y)
 
Makes sense, I'll play with it a bit more when I get home, thanks for the help!
 
No problem. Feel free to ask questions here any time, and also check out the learning resources on APL Wiki.
 
 
1 hour later…
9:22 PM
with quite a bit of work (most of which was mostly completely pointless), i've sped {+/1,⍵+1}¨⍳1000 up from an avg 15.6ms to ~9ms. Not nearly what i was hoping for ((+/1,+∘1)¨⍳1000 is 0.1ms), but ¯\_(ツ)_/¯ (i'll probably attempt more optimization at some point later)
 
@dzaima How does this stack up against Dyalog? And is there a difference between +/ and 1⊥?
@dzaima Are you not muddling things by both doing two memory copies (+1 and 1,) and a summation?
@dzaima You have a hundred-fold difference between a dfn and the equivalent tacit function‽
 
@Adám ]runtime -r=10000 {+/1,⍵+1}¨⍳1000 gives 0.35, (+/1,+∘1)¨⍳1000 gives 0.47ms - so dzaima/APL may be faster than Dyalog in very unAPLy code :p
@Adám Eeeexactly. That's what I was hoping to fix (without having to redo the whole eval code). The couple temporary objects are nothing in comparison (it's just dummy code for the purpose of adding tokens in the dfn to be parsed)
 
9:41 PM
]runtime -c {+/1,⍵+1}¨⍳1e4 {1⊥1,⍵+1}¨⍳1e4
 
@Adám

  {+/1,⍵+1}¨⍳1e4 → 4.6E¯3 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  {1⊥1,⍵+1}¨⍳1e4 → 3.2E¯3 | -31% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 

« first day (1120 days earlier)      last day (1524 days later) »