« first day (1567 days earlier)      last day (1080 days later) » 

2:07 AM
what is the point of the Symbol => ⍤ 3 1 4 1 5~ ⍤ ∊ 1 2 3 <=> ~(3 1 4 1 5 ∊ 1 2 3)
why would I need ⍤ ?
 
has two meanings: Atop and Rank. Function composition like that is called an Atop, and you can perfectly write APL code without Atop at all.
But it allows to write a certain kind of composition nicely, like |⍤- being absolute difference of two numbers
 
2:41 AM
v ← 2 1 3
v
2 1 3
vv ← ⍋v
v[vv]
1 2 3
How can I use the similar syntax for matrix? assume I want to sort each rows on a matrix
 
rand44 ← 4 4⍴16?16
rand44
┌→──────────┐
↓ 3 16 13 4│
│11 1 8 7│
│12 6 2 10│
│ 9 15 5 14│
└~──────────┘
⍋rand44
┌→──────┐
│1 4 2 3│
└~──────┘
rand44[⍋rand44;⍳4]
┌→──────────┐
↓ 3 16 13 4│
│ 9 15 5 14│
│11 1 8 7│
│12 6 2 10│
└~──────────┘
rand44[⍳4;⍋⍉rand44]
┌→──────────┐
↓ 3 4 13 16│
│11 7 8 1│
│12 10 2 6│
│ 9 14 5 15│
└~──────────┘
Ah, per row
Hm
↑{⍵[⍋⍵]}¨↓rand44
┌→────────┐
↓3 4 13 16│
│1 7 8 11│
│2 6 10 12│
│5 9 14 15│
└~────────┘
 
3:00 AM
↑ ↓ why we need both? can you explain a bit?
I could imagine map(\x -> ⍵[⍋⍵] ) rank44
 
@elliptic00 I don't particularly get it myself, as I'm also still learning, but it seems to be because you need a vector of rows, and a matrix doesn't decompose that way unless you Split it
 
oh.. I think I got it. . ↓ mat. => convert rank 4, 4 to rank 4, so you can map each rows, and use ↑ to convert rank 4 back to rank 4, 4
 
That is about how I understand it, yes
 
nice one. anyway
 
Usually ⍤1 works for "for each row"
so "sort each row" can be written as {⍵[⍋⍵]}⍤1
 
 
1 hour later…
4:36 AM
{⍵[⍋⍵]}⍤1 also works for rank 3 matrix, .. nice once
mm ← 2 3 4 ⍴24?24
I'm really wondering what does it mean {⍵[⍋⍵]}⍤2 ?
{⍵[⍋⍵]}⍤2
 
@rcabaco You may want to try ⎕ARBOUT rather than the default output.
 
@elliptic00 It wouldn't work because the bracket notation only works for a vector
 
Oh.. I see
 
For a matrix, it would be {⍵[⍋⍵;]}, which sees each row as one item and sorts the rows
 
A better way to write {⍵[⍋⍵]} is {(⊂⍋⍵)⌷⍵} which works on all ranks.
 
4:42 AM
^
Or ⊂⍤⍋⌷⊢ as a train
 
Or ⍋⌷⍤0 99⊢
 
Actually I just realized the train also works dyadically if I replace the classic with
 
Anyway, with any of these, you can use ⍤k to sort sub-arrays of rank k rather than the entire array.
(And you can sort the entire array with k←99)
      m←3 3 3⍴?⍨27
      m ({(⊂⍋⍵)⌷⍵}⍤1⊢m) ({(⊂⍋⍵)⌷⍵}⍤2⊢m) ({(⊂⍋⍵)⌷⍵}⍤3⊢m)
┌────────┬────────┬────────┬────────┐
│22  4 10│ 4 10 22│ 5  7 15│13 16 12│
│ 6 19 24│ 6 19 24│ 6 19 24│27 11  8│
│ 5  7 15│ 5  7 15│22  4 10│21  2 14│
│        │        │        │        │
│13 16 12│12 13 16│13 16 12│17 20 26│
│27 11  8│ 8 11 27│21  2 14│ 1  3 18│
│21  2 14│ 2 14 21│27 11  8│23  9 25│
│        │        │        │        │
│17 20 26│17 20 26│ 1  3 18│22  4 10│
│ 1  3 18│ 1  3 18│17 20 26│ 6 19 24│
│23  9 25│ 9 23 25│23  9 25│ 5  7 15│
@Bubbler (Indeed, hence the pity that only {(⊂⍋⍵)⌷⍵} and the bracket axis ones are optimised.)
 
5:05 AM
⊂⍋⍵ what does it mean? can you guys explain a bit?
I never understand what Enclose in RIDE, all I see in RIDE, there is box and box..
 
is the indexing function, which takes a left argument with one element for each ;-delimited "section" you'd see in m[;;].
Since we only want to index along the leading axis, all the indices need to go into the first section, so we need to enclose them. Otherwise, a b c⌷m would be interpreted like m[a;b;c] rather than m[a b c;;]
@elliptic00 RIDE is just an interface, the language is (Dyalog) APL. Anyway, packages any array into a scalar.
@Wolgwang Hi and welcome. Interested in APL?
 
I wish RIDE have one line description: ⊂ packages any array into a scalar.. :).. this is why all I see ⊂ on RIDE, box and box.. :)
I have no idea box means a scalar.. or something similar...
 
@elliptic00 Maybe APLcart's one line descriptions could be valuable to you, e.g.: aplcart.info?q=⊂ primitive
 
Ah, the one-word description... it's only useful when you're already familiar with it
 
@elliptic00 Btw, you can also look at the full documentation (which, admittedly, isn't very long) by typing and pressing F1, or by entering ]help ⊂ ― but for a more in-depth discussion about a primitive, I definitely recommend APL Wiki.
 
5:15 AM
@Adám Never tried but seems interesting.
 
@Wolgwang Reading your profile, it sure would seem a good fit for you. Do you do any programming?
 
@Adám Python but basic..
 
@Wolgwang I just looked at your top post which has the formula
It might interest you that D ≡ d + c_m + c_y + c + ⌊c÷4 is valid APL…
APL was created by a mathematician, the same one that invented the ⌊𝑥⌋ notation
 
For more amusement (and accuracy), replace with ≡⍥(7∘|), because it's equivalence mod 7
 
@Bubbler Actually, D is already 0…6 so D ≡ 7| d + c_m + c_y + c + ⌊c÷4
Is the TMN (Traditional Mathematical Notation) not ambiguous in the original formula? Does (mod 7) apply to ≡ or only to the sum?
(Of course, that doesn't matter when D is in the range [0,6] but if it wasn't?)
 
5:25 AM
A ≡ B (mod m) notation is standard in elementary number theory. If you want to take the remainder of dividing an expression by m, you write "mod m" without parens. But then there's always a question of precedence of "mod"
 
@Rover Hello. Interested in APL?
 
@Adám I just came by seeing what's APL, I am interested in almost everything I see new , but there's no time to do anything for a year ..
 
@Rover Fair enough. APL is an executable mathematical notation. It extends arithmetic and linear algebra to the point where you have a fully powered programming language.
 
Wow, sounds interesting
 
One of the nice things it takes from linear algebra, is implicit "mapping", so you rarely need an explicit loop. E.g. to multiply the vector (3,1,4) with 2, you can simply write 2×(3,1,4) ― yes, with a proper multiplication sign.
 
5:37 AM
Okay
 
However, APL also makes a point out of generalising Traditional Mathematical Notation (TMN).
So while (3,1,4)∙(2,7,1) is the dot product in TMN, namely 3×2 + 1×7 + 4×1, APL allows you to choose any to operations to combine the elements of the vectors.
(3,1,4)+.×(2,7,1) is the traditional dot product, but nothing prevents you from writing e.g. (3,1,4)+.÷(2,7,1) meaning 3÷2 + 1÷7 + 4÷1.
 
Ok, but for this year I am learning python as it's in our course.
 
No problem. You're always welcome here.
 
Thanks @Adám :-)
 
6:04 AM
@Adám If we were indexing along the second axis, like [;a b c;;...] for example, how would you go about it?
 
@Sherlock9 Using you mean?
 
Yep
I figure the simplest solution is to transpose the two axes, sort, and then transpose back
... Then again, I forget how to transpose two axes in that way
 
(⊂a b c)⌷⍤0 ¯1⊢x maybe?
 
2 1 3⌷⍤0 2⍤1 2⊢m or (⊂2 1 3)⌷[2]m or (⊂2 1 3)⌷⍤2⊢m
@Bubbler You don't need that 0 there and your ¯1 is equivalent to my 2
 
Yeah, Idk why I put it there
 
6:09 AM
:-( Again, we need "The Indexer" a.k.a. "Sane indexing" a.k.a. Select.
With I←⌷⍨∘⊃⍨⍤0 99 it is simply a b c(I⍤2)m
 
I look forward to sane indexing showing up in Dyalog XX.0 :D
 
6:24 AM
I'm trying to argue that rather than redefining X⍋Y to be X⌷⍨⊂⍋Y so that sorting may be written as ⍋⍨Y we should add so sorting can be written (⍋⊇⊢)Y as Select/Permute adds much more versatility than Sort-by.
Ideally, I'd also want reverse-compose so sorting can be written as ⍋⍛⊇⍨Y and Sort-by as X⍋⍛⊇⍨Y
 
6:53 AM
      f←{...} ⍝ sort down columns I guess?
      m←3 3 3⍴?⍨27
      m,(f m)
┌→────────────────────────┐
│ ┌┌→───────┐ ┌┌→───────┐ │
│ ↓↓21 14  3│ ↓↓6  8  3│ │
│ ││19  8  5│ ││19 14  5│ │
│ ││ 6 17 12│ ││21 17 12│ │
│ ││        │ ││        │ │
│ ││27  7  1│ ││10  7  1│ │
│ ││20 11 23│ ││20 11 22│ │
│ ││10 18 22│ ││27 18 23│ │
│ ││        │ ││        │ │
│ ││13 16  4│ ││13  2  4│ │
│ ││15  9 25│ ││15  9 25│ │
│ ││24  2 26│ ││24 16 26│ │
│ └└~───────┘ └└~───────┘ │
└∊────────────────────────┘
I was more looking for something like this
 
Then you're supposed to transpose and sort each row, yes
 
Ahh, thanks
How do I transpose specific axes?
Say I have a 5D array for some reason and I need to transpose axes 1 and 4
 
4 2 3 1 5⍉array
Swapping two axes x and y is easy: write down 1 2 .. n (where n is the rank of the input array) and swap the two numbers x and y
 
does anyone know where RIDE store all session data or session file, I want to backup my RIDE session data
I'm looking at the "Preferences" in the menu, and there is on session path or something? do I'm missing something?
no session path..something..
 
I think I'm going to have to keep playing around with rank and axes for a while before I get it. Are there any resources for studying up? One of the conversations, a wiki page, or a paper?
 
7:07 AM
I might forgot all the APL symbol next week.. If don't use it for a week.. :)
 
7:20 AM
@elliptic00 Try ⎕SE.File
 
7:45 AM
where is what I got after Box.SE.File
/Applications/Dyalog-18.0.app/Contents/Resources/Dyalog/default.dse
so I assume default.dse is the session file?
 
is there an ⎕DR for functions?
 
8:28 AM
@elliptic00 Yes.
@Razetime ⎕DR is Data Representation. Functions are not data. Do you want to know what style (tradfn/dfn/tacit) or syntactic class (fn/op) or syntax (niladic/monadic/dyadic/ambivalent) a certain function has?
 
8:45 AM
yeah basically an ⎕FR type thing
 
@Razetime {⎕NC⊂,⍵} will give you 3 for function and 4 for operator, plus .1 for trad-, .2 for d-, and .3 for tacit. ⎕AT gives you r f o where r is result/noresult (negative for shy), f is 0/1/2 for niladic/monadic/dyadic function (¯2 for ambivalent), and o is 0/1/2 for not/monadic/dyadic operator.
 
uh wow
that just.. solves the whole thing
I'm assuming there is the string representation of the function?
 
No, the argument is the name of the function.
Btw, it should say ⊃⎕AT not plain ⎕AT
 
9:00 AM
now for another question: can I uae ⍺ and ⍵ in place of a and w here?
 
      repr←'r←{x} foo y' ''
      ⊃(⎕NS⍬).(⎕AT⎕FX)repr
1 ¯2 0
      ⊃(⎕NS⍬).(⎕NC∘⊂⎕FX)repr
3.1
@Razetime Should I stack those on the 'cart?
 
yeah, sure
 
 
3 hours later…
12:19 PM
@Adám neat. Now i just need to find a way to get stdout as ⍺ for ⎕ARBOUT
 
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket. File descriptors typically have non-negative integer values, with negative values being reserved to indicate "no value" or error conditions. File descriptors are a part of the POSIX API. Each Unix process (except perhaps daemons) should have three standard POSIX file descriptors, corresponding to the three standard streams: == Overview == In the traditional implementation of Unix, fi...
 
@Adám Yes. Going to try now ⎕NTIE with /dev/stdout
@Adám Using the FD for stdout was my first attempt but got me a domain error
 
12:40 PM
No luck. I imagine the Dyalog session in the terminal is catching all of this.
 
@rcabaco if you're starting a session, it will indeed eat all the output
 
@dzaima is there a way not to start a session?
 
dyalog -script somefile with somefile being ⎕←'hi' works
 
running ./dyalog load=, starts a session
strange, i get no output from thta
*that
 
add a trailing newline to the file maybe?
 
12:46 PM
that was it. thank you
Still no luck with the ansi control sequences tough
 
anything specific? e←⎕ucs 27 ⋄ ⎕←e,'[38;5;123mhello',e,'[0m' works for me
 
No. I was just trying out. From your code I see my error:the start character
 
1:05 PM
This is nice. One can use this to implement TUIs.
There exists ⎕SM but from what I can tell it is only for forms.
Or.. Is the Dyalog terminal session implemented with ⎕SM?
 
@Adám In the talk Roger Hui gave about the rank operator, he's asked about a possible axis operator. Did that ever materialize?
 
1:38 PM
@Sherlock9 f[ax] already exists, but it is impossible to create a general-purpose one.
@rcabaco I think so. I think it can draw anything, but is especially equipped to do forms well.
 
Impossible as in the language as currently specified would have to be immensely hacked to get an axis operator to work, or impossible as in any possible specification for an axis operator spawns fractal headaches?
 
@Adám i am looking at the sm workspaces trying to find out what it can do.
 
@Sherlock9 Impossible because there is no system to how [ax] modifies the function. It is defined separately for each allowed function.
 
Eugh, fair enough
For the record, I'm throwing "every time we implement it, it's inconsistent with the other implementations" into the "fractal headaches" bin
 
@Adám Not sure if it is relevant for Dyalog, but smdesign.ws gives a domain error on launch:
Reading APL format file /Applications/Dyalog-18.0.app/Contents/Resources/Dyalog/.
\aplfmt\default.DFT .../usr/bin/TYPE: line 4: type: /Applications/Dyalog-18.0.app
DOMAIN ERROR: Command interpreter returned failure code 1
SMGETFMT[15] FILE←⎕CMD'TYPE ',FILE

/Contents/Resources/Dyalog/.aplfmtdefault.DFT: not found
 
2:01 PM
@rcabaco Can you email support@dyalog.com with that?
 
⎕cmd'type ',file is such a stupid hack :D
(and maybe broken too, if the name contains spaces)
 
@dzaima How would you do it?
(Other than adding quotes and/or escapes.)
 
@Adám use ⎕nget or whatever
 
Probably didn't exist when it was written.
 
2:27 PM
which is kinda stupid
 
It is stupid that ⎕NGET didn't exist when the code was written‽
 
that at some point someone had reason to think that ⎕cmd and broken string concatenation is the best way to read a file
 
Ah, yes, that does seem silly. ⎕NREAD has always been around.
 
well, then that one-liner would've been a long mess or creating a tie number, reading as bytes, converting to unicode array, splitting on lines, and closing the tie number. It's understandable that one would prefer ⎕cmd over that mess
 
You would have thought someone would write a cover function doing all that. (Hint: Someone did.)
 
2:37 PM
at least they made 'TYPE ' uppercase, otherwise it would quietly give a completely unrelated string on linux
@Adám the lack of a usable standard library means everyone has to re-write it (and remember the location and name for that one specific project)
 
Or copy it from somewhere, yes.
I'm 100% with you that we need a stdlib.
CMQ: I'm planning on hosting a Zoom meeting every 4 weeks, where the subject is the history of APL and those involved with it. What should I call the event?
 
2:53 PM
"Since Scholes" maybe?
 
I don't get it.
 
3:38 PM
APLP: A Programming Language Podcast
 
1) Not a podcast. 2) Doesn't imply anything with history or old-timers.
One suggestion is APL Dinosaurs but can it be considered offensive?
 
Rings on the APL Tree
Subtitle: APL Through the Years
 
APL Tree Rings
 
Aha! We have golfed it!
 
Colloqually referred to as ATR.
CMC:
0
Q: Sine of x using ONLY arthemetic operators

Maanas BThe challenge. Implement a sin function without using any builtin sin function. The sin function must be implemented using only these +, -, ×, ÷ (basic arthemetic operators)and must have an accuracy of upto 3 decimal places. Example NOTE: The input is radians and the range is -2π to 2π sin(π) ->

You can use operators and mixed (non-scalar) functions too.
 
4:08 PM
This is what I used in BQN before adding •math, and it has a maximum error of about 0.0016.
It uses modulus. Doing it for that large of a range without modulus or floor would require a ton of coefficients.
 
4:21 PM
@Adám I wouldn't say it's that offensive but I think ATR is a better name anyway
 
      f←{0j2÷⍨-/*(⊢,-)0j1×⍵}⋄(f 3),1○3
0.1411200081 0.1411200081
@Adám i think this ↑ is the right formula
 
@Razetime * isn't allowed.
 
hm, ok
 
      f←{-/(⍵∘*÷×/⍤⍳¨)¯1+2×⍳9} ⋄ (f 3),1○3
0.1411200174 0.1411200081
 
taylor series?
 
4:26 PM
Yes.
 
very nice
 
Using Bhaskara I's approximation formula {z←4×⍵×+/¯1 ○1⋄4×z÷z-⍨○1}
Which I think is the same as Marshall's BQN solution
 
i don't think arcsin is allowed but you can probably sub it in for a constant
 
Bugger, I meant for that to be pi
{p←∘1⋄z←4×⍵×+/p ¯1⋄4×z÷p-z}
Oh wait, {p←∘1⋄z←4×⍵×p-⍵⋄4×z÷-z} Correct and golfier
 
p←∘1 not p←○1?
 
4:32 PM
{p←○1⋄z←4×⍵×p-⍵⋄4×z÷-z} Oh no wonder
And I missed that it's 5 pi^2 in the denominator {p←○1⋄z←4×⍵×p-⍵⋄4×z÷z-⍨×/5p p}
 
@Adám Interesting.
 
4:51 PM
@Adám This can be decomposed into a product scan, provided you throw out the even terms afterwards. 18 in BQN.
Of course the actual mathematical version would be to multiply terms by powers of i, add them, and take the imaginary part.
 

« first day (1567 days earlier)      last day (1080 days later) »