« first day (1051 days earlier)      last day (1619 days later) » 
02:00 - 23:0023:00 - 00:00

11:01 PM
⋄ IsDivisibleBy←{(⍺÷⍵)=⌊⍺÷⍵} ⋄ DivTable←{(⍳⍵)∘.IsDivisibleBy ⍳⍵} ⋄ ⎕←+/DivTable 20
 
@frank
1 2 2 3 2 4 2 4 3 4 2 6 2 4 4 5 2 6 2 6
 
⋄ IsDivisibleBy←{(⍺÷⍵)=⌊⍺÷⍵} ⋄ DivTable←{(⍳⍵)∘.IsDivisibleBy ⍳⍵} ⋄ PrimesUntil←{(⍳⍵)[⍸(+/DivTable⍵)-2]} ⋄ PrimesUntil 20
 
@frank
DOMAIN ERROR
 
⋄ IsDivisibleBy←{(⍺÷⍵)=⌊⍺÷⍵} ⋄ DivTable←{(⍳⍵)∘.IsDivisibleBy ⍳⍵} ⋄ PrimesUntil←{(⍳⍵)[⍸(+/DivTable⍵)-2]} ⋄ ⎕←PrimesUntil 20
or no
⋄ IsDivisibleBy←{(⍺÷⍵)=⌊⍺÷⍵} ⋄ DivTable←{(⍳⍵)∘.IsDivisibleBy ⍳⍵} ⋄ PrimesUntil←{(⍳⍵)[⍸2=+/DivTable⍵]} ⋄ ⎕←PrimesUntil 20
 
@frank
2 3 5 7 11 13 17 19
 
11:04 PM
All right
 
Well done!
You've now written a mathematical formula for the set of primes!
@frank Exhausted or still up for more?
 
Im still up for more
 
OK. So far we've done numeric arrays, but characters are actually scalars just like numbers. The only difference is really that you can't do arithmetic on them. Strings are simply character vectors, and nothing prevents you from making character arrays of any number of dimensions:
⎕←3 4⍴'abcde'
 
@Adám
abcd
eabc
deab
 
Btw, the 'string' notation is a shortcut for writing each scalar character separately:
⍞←'abc'≡'a' 'b' 'c'
 
11:08 PM
@Adám 1
 
Now write the function SpaceFree which removes spaces from a given string: SpaceFree 'hello, how are Y O U ?' should give 'hello,howareYOU?'
Btw, you may want to press Ctrl-K (or insert 4 spaces before your code) when you write APL code. This switches the message to monospace, and preserves white-space.
 
⋄ SpaceFree←{⍺-' '} ⋄ ⎕←SpaceFree 'hello, how are   Y O U   ?'
 
@frank
VALUE ERROR
 
@frank Hey, you can't do arithmetic on characters!
 
⋄ SpaceFree←{⍵-' '} ⋄ ⎕←SpaceFree 'hello, how are Y O U ?'
 
11:13 PM
@frank
DOMAIN ERROR
 
ah right
 
So notice that APL doesn't overload functions like + to concatenate strings.
 
⋄ SpaceFree←{⍵[⍸~⍵=' ']} ⋄ ⎕←SpaceFree 'hello, how are Y O U ?'
 
@frank
hello,howareYOU?
 
im doing alright thanks Dyalog bot
 
11:15 PM
Very nice. You were pretty quick solving this one.
 
⍸ is very useful haha
 
Indeed.
Now the only thing you're really missing is building your APL vocabulary. At this point, you can basically start leaning each built-in function and operator, either in order or as you need them.
 
is there a list of APL instructions somewhere, for reference?
 
Not to cause you unnecessary typing, I'll tell you that the Count function exists as (it looks like a tally mark) and reverse is (the vertical bar indicating the mirror), and set difference is dyadic ~ (just like monadic is "not", so is dyadic "but not").
@frank Oh yes, there's a full documentation suite.
@frank Also, these chat lessons might be exactly what you need now.
 
Ill look through these lessons, thanks
do you host them often?
 
11:23 PM
I ran the first 29 weekly over half a year, a while back. Then I recently began a new series focusing on topics/challenges which I plan on giving every two-three weeks.
However, I'm usually in this room, and there are often many others here to answer questions, discuss matters, and post challenges.
 
I see, Ill check back in now and then
Thanks for the intro to APL, it was really interesting
 
You're very welcome. If you want more basic challenges, check out the "Phase I" tasks from our yearly problem solving competition.
 
@frank @Adám Thanks to you both for going through this. As someone who is still learning the APL ropes, this was a very nice refresher/primer!
 
@codesections Cool to have done double duty. Talk about array processing…
 
@Adám Will there be any new idioms for 18.0? If you're taking requests, I'd love to get ⊂⍒ and ⊂⍋ as idioms for "index of max/min"
 
11:32 PM
Even if here is not this way "each of zilde" is zilde...right? "function each of zilde" is zilde, right?
 
@voidhawk You mean ⊃⍋ and ⊃⍒
 
Yeah sorry, typo
 
@RosLuP No, f¨⍬ is 0⍴⊂f 0
 
I've been using (⊢⍳⌈/) to avoid the sort overhead but it doesn't look as nice ⍨
 
@voidhawk You're not the only one who requested this. It came up in AoC, right? We are kind-of holding back on adding new idioms, as we are contemplating a new system called Thunks.
 
11:38 PM
Yeah, it was actually suggested by Jay Foad
 
Don't know for the remain, but each of void set is void set; each of zilde has to be zilde
 
@RosLuP No, each of a void set is indeed a void set, but a set void of what? Do you not agree that ⎕UCS¨⍬ should give '' and not ?
 
11:54 PM
Seen result... ,/each /zilde has to be the void list (as ,/each 1 2 3 has to be 1 2 3 as list)
Here it return not zilde but one 0 elements array deep 2 contain the list contain one element 0; so one list of zero elemnts contain one list?
 
@RosLuP No, it does return zilde:
⍞←⍬≡,/¨⍬
 
@Adám 1
 
02:00 - 23:0023:00 - 00:00

« first day (1051 days earlier)      last day (1619 days later) »