« first day (1705 days earlier)      last day (1102 days later) » 

3:40 AM
On Windows, how to use an .apl file ?
I would like to load this script on Dyalog APL on windows github.com/ashinkarov/cnn-in-apl/blob/master/cnn.apl
 
4 hours later…
7:24 AM
@brgal That isn't an official format until version 18.2, but this seems to work:
⎕FIX(⊂':namespace'),(⊃¯2↓⎕nget'cnn.apl'1),'⎕←main 0' ':endnamespace'
 
2 hours later…
SJT
SJT
9:05 AM
I have lost touch with iteration in Dyalog. Here is a simple Eratosthenes’ Sieve.
```apl
sieve4←{p←1+⍵⍳1 ⋄ (⍺,p) (⍵∧(≢⍵)⍴((p-1)⍴1),0)}
1 sieve4 0,20⍴1
1 3 0 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0
```
It returns a pair: the arguments for the next iteration. Questions:

1. How to iterate N times?
2. How to iterate until the result stops changing?
f⍣n to repeat a function n times, and ⍣≡ to repeat a function until the return value doesn't change
SJT
SJT
Ha! Tx. I used the q symbol for Match (~) by mistake! Simple enough to make the function monadic, but are there answers for the dyadic function?
(there's no markdown in multiline messages. You only get to code-block the whole thing with ctrl+k)
you can do ⊃f/ to call a function dyadically by a list of the arguments
(would need to be (⊃{…}/)⍣)
SJT
SJT
9:22 AM
Tx! The equivalent iteration syntax in q gives me a choice between returning (a) a list of results from each iteration (c.f. Scan in APL) and (b) just the last result. An internal assignment to Quad would emulate (a) for debugging. But is there a syntax that returns (a) as a result?
9:35 AM
there is none
you have to do it manually
@Adám could do with "cumulative" (and maybe "scan") as keywords
@dzaima Building…
SJT
SJT
10:15 AM
Now my sieve works..
      ⎕IO
0
      sieve←{⍵∧.=0:⍺ ⍵ ⋄ p←1+⍵⍳1 ⋄ (⍺,p)(⍵∧(≢⍵)⍴((p-1)⍴1),0)}
      ]disp (⊃sieve/) 1 (0,19⍴1)
┌→──┬───────────────────────────────────────┐
│1 2│0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0│
└~─→┴~─────────────────────────────────────→┘
And I can iterate until all the 1s have been tested.
      ]disp (⊃{⍵∧.=0:⍺ ⍵ ⋄ p←1+⍵⍳1 ⋄ ⎕←(⍺,p)(⍵∧(≢⍵)⍴((p-1)⍴1),0)}/)⍣≡ ⊢ 1 (0,19⍴1)
 1 2  0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
 1 2 3  0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0
 1 2 3 5  0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0
 1 2 3 5 7  0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1 0
 1 2 3 5 7 11  0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0
 1 2 3 5 7 11 13  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
 1 2 3 5 7 11 13 17  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
 1 2 3 5 7 11 13 17 19  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
But of course I do not need to do this. Once I have found a prime ≤ the square root of N, where N is the length of the bit vector, all the remaining 1s mark primes.
I can replace the internal test for all 0s with an external test: have we found a large enough prime yet?
      ]disp {⍺,1+⍵/⍳⍴⍵}/(⊃{p←1+⍵⍳1 ⋄ ⎕←(⍺,p)(⍵∧(≢⍵)⍴((p-1)⍴1),0)}/)⍣{5≤⊃⌽⊃⍺} ⊢ 1 (0,19⍴1)
 1 2  0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
 1 2 3  0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0
 1 2 3 5  0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0
┌─────────────────────┐
│1 2 3 5 7 11 13 17 19│
└~───────────────────→┘
Now I have a scope issue. The 5 in the test function {5≤⊃⌽⊃⍺} is of course the ceiling of the square root of 20, the length of the bit mask. There is no need to calculate it on each iteration. But it turns out I can calculate it once and the test fn can read it.
      ]disp { L←⌊(≢⍵)*¯1 ⋄ {⍺,1+⍵/⍳⍴⍵}/(⊃{p←1+⍵⍳1 ⋄ (⍺,p)(⍵∧(≢⍵)⍴((p-1)⍴1),0)}/)⍣{L<⊃⌽⊃⍺} ⊢ 1 (0,1↓⍵⍴1) }20
┌──────────────────────────┐
│1 2 3 5 7 9 11 13 15 17 19│
└~────────────────────────→┘
Cleaning that all up...
      sieve←{⍵∧.=0:⍺ ⍵ ⋄ p←1+⍵⍳1 ⋄ (⍺,p)(⍵∧(≢⍵)⍴((p-1)⍴1),0)}
      es←{ L←⌊(≢⍵)*¯1 ⋄ ⊃{⍺,1+⍵/⍳⍴⍵}/(⊃sieve/)⍣{L<⊃⌽⊃⍺} ⊢ 1 (0,1↓⍵⍴1) }
      es 20
1 2 3 5 7 9 11 13 15 17 19
What are the scoping rules that make L visible here to the test function?
10:38 AM
@SJT Lexical. L is defined inside es so everything es defines can see L.
@SJT Btw, no need for that
SJT
SJT
So dfns have the same scope rules as tradfns? (I thought I remembered there is a difference.)
Tradfns use dynamic scope. Everything I call can see what I've defined.
@SJT (≢⍵)*¯1 is ÷≢⍵ and ⍵/⍳⍴⍵ is ⍸⍵
@Adám Thanks Adám !
SJT
SJT
How is ÷≢⍵ square root?
How is (≢⍵)*¯1 square root?
Did you mean (≢⍵)*0.5?
@SJT 0,1↓⍵⍴1 is ~⍵↑1
SJT
SJT
10:44 AM
Ouch, yes.
Nor do primes start at 1.
      { L←⌊(≢⍵)*.5 ⋄ ⊃{⍺,1+⍸⍵}/(⊃sieve/)⍣{L<⊃⌽⊃⍺} 2 (0,2|⍳⍵-1) }20
2 3 5 7 11 13 17 19
Tx. Good to catch up a bit with Dyalog!
 
2 hours later…
1:03 PM
@Adám so in 18.2 we migt be able to use dyalogscript?
1:15 PM
@pVCaecidiosporeadduced Yes.
 
1 hour later…
2:21 PM
@Adám Why is that? Were there problems with 18.0 or is 18.2 supposed to be separate from that, kept for backwards compatibility?
Thanks!
 
3 hours later…
5:40 PM
Announcement: APL Campfire in 20 minutes on Zoom. Passcode: The result of ×/1966 11 27 evaluated as APL.
 
3 hours later…
8:48 PM
Announcement: The APL Campfire event featuring Geoff Streeter and Andy Shiers is now available on YouTube:
 
2 hours later…
10:19 PM
@Adám You remember helping with with the ⎕LX expression a week or so ago?
I managed to get it working, but now I can't open the dang workspace! :C
]load 'my.dws'
* Command Execution Failed: Invalid UTF-8 sequence
because the ⎕LX is expecting a string, but I don't know how to open the WS without firing the ⎕LX expression
10:53 PM
@nathanrogers What did you search for on APLcart?
⎕LX, I found the command line option -x in the docs
but I flat can't even open the file
I'm not running "dyalog my.dws -x"
I have dyalog open and trying to ]load it
I also looked for ]laod
]load is for SALT files. Workspaces are not SALT files.
ws not found
)xload my.dws
ws not found
)xload 'c:\absolute\path\to\my.dws'
same thing
10:56 PM
Use double quotes. (Or no quotes, if there are no spaces etc.)
oh, well why is that the case?
Because nobody asked me how it should be designed.
:P ok well thanks for that
I did look, but I couldn't get it to work
I should add an example
I can't say I've ever had to use double quotes
11:01 PM
Yeah, it is a mess. I my opinion, all commands should just go away, and be replaced by functions where appropriate.
18.2 will have a new ]get command (!) which should work for most cases of wanting to get anything from anywhere.
@Adám suggestions for the cart, unix timestamp related things could be handy
11:19 PM
@rak1507 Good idea.
And in general, all the names for all the formats should bring up ⎕DT
yep, definitely

« first day (1705 days earlier)      last day (1102 days later) »