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

4:52 AM
CMQ: If a noun (array) should start with lowercase and a monadic/dyadic verb (function) should start with uppercase, what about a niladic tradfn that returns an array?
@Adám ^
 
 
1 hour later…
6:12 AM
@Bubbler lowercase. The first letter rule would be to help humans parse, and syntactically, a niladic tradfn parses exactly like an array. That said, I'd normally avoid niladic tradfns other than for things like returning a cache or loading something into its own place.
 
6:30 AM
@Adám Thanks. I realized it only after I already wrote 30 solutions to Advent of APL. (I was writing niladic tradfns in uppercase until now.)
 
@Bubbler You're not doing anything wrong. This is just my personal convention. Dyalog's "official" internal convention includes uppercasing all tradfns, niladic or not.
 
@Adám Oh.
Probably it'd be better to have a unified convention before APM starts accepting user packages.
 
@Bubbler I agree. I'll suggest it. Thanks.
 
Also, auto-formatting in a scripted ns looks a bit weird to me (example).
Inline defs are indented 4 spaces while multiline dfns are indented 6 spaces, as if the whole definition is enclosed in del symbols like a tradfn.
 
6:46 AM
@Bubbler I know. tradfns and dfns and tacit fns use 3 different rules. Almost as if three different people designed them. Oh.
@Bubbler RIDE has the option to do its own formatting which at least makes all three have the same indent. But of course, that isn't available in the Windows IDE.
 
@Adám I didn't know RIDE supports that. (And I do use RIDE both on my local PC and on the cloud.)
 
7:50 AM
@Adám Also, it'd be handy to have "format source" functionality (either button or context menu is fine) in the RIDE editor.
 
8:33 AM
@Bubbler Why don't you suggest that?
 
 
6 hours later…
2:12 PM
@Adám ping
 
@aierl OK, good. It works.
 
3:07 PM
Hi, i'm very new to apl, i'm trying to do something i thought simple but i'm having a lot of problems:
i have an vector of string and i want to filter it out given another string
 
@GabrieleCarrettoni vector~⊂string
 
why the = doesn't work?
(thanks btw)
to get the boolean mask
what i'm actually trying to do is, given a table take only the rows that have a column with a string value that i pass to the function
 
@GabrieleCarrettoni = vectorizes to all depths, so 'ab' 'cd'='ef' would be equal to ('ab'='e')('cd'='f') which in turn would be (('a'='e')('b'='e'))(('c'='f')('d'='f')). You probably want vector≡¨⊂string
 
i thought about getting the column i want, get the boolean vector and then filter matrix
@dzaima thanks, that is exactly what i wanted, i got to the equality and enclosure but didn't realize i had to combine it with map
now i'll have to understand how to filter out the matrix using this boolean vector
 
@GabrieleCarrettoni Just use booleanVector⌿matrix
 
3:19 PM
ah! thanks
 
3:39 PM
i have to say it is not easy these days to bring about motivation to spend an enormous time learning APL, given all the other languages/opinions/real world stories when one does not have the technical abilities to silence the "dragon" in the brain. So any small win gives me a smile and a boost. Example (perhaps familiar to you): blog.cleancoder.com/uncle-bob/2019/08/22/WhyClojure.html
i opened Dyalog, stopped for a little and came up with: ×⍨⍳25
then i smiled
carry on.
 
4:13 PM
@GabrieleCarrettoni APLcart may help you.
 
4:24 PM
@Adám in the APL_Wiki_logo article of the wiki, i think i found two errors in the code samples:
r←⌊∘.+⍨.5×4!⍨⍳5 is defined and the next snippet calls "sizes" to r
"locs" is used but not defined
 
hola
@Adám yes sir
 
@ThePuzzlerThree When is good for you? In an hour?
 
ngn
@rcabaco "No. Clojure is not slow." lol :)
 
@ngn i have no idea really (although some Lisps are quite fast), i got to the page because of comment on reddit about succinctness and expressiveness
 
ngn
4:49 PM
@Bubbler you can untick "handle formatting through interpreter" (prefs>general) and remap <RD> (prefs>shortcuts) but it seems broken
 
@Adám i can do now if you are free
 
@ThePuzzlerThree I can do in half an hour.
 
5:11 PM
@Adám never mind-3:30 est?
@Adám thats 20:30 uct
@Adám never mind go with 19:30 uct
 
5:26 PM
@ThePuzzlerThree 19:30 UTC is a deal.
 
@Adám thanks
/c should be about 1 and a half hours of free time
@Adám should be about 1 and a half hours of free time
 
perfect
 
 
2 hours later…
7:30 PM
@ThePuzzlerThree Ready?
 
8:04 PM
@Adám i meant an hour after you posted that
@Adám im ready now
@Adám ping me when ur ready
 
@ThePuzzlerThree OK, lets get started.
Right, we were up to using array processing instead of if-statements.
 
Say you wanted to add 10 to all the numbers that are less than 5.
In a traditional language, you'd loop through the numbers with an if-statement for each one.
 
In APL, you'd prefer to use a formula like myNumbers+10×myNumbers<5
⋄ myNumbers←3 1 4 1 5 9 2 6 5 ⋄ ⎕←myNumbers+10×myNumbers<5
 
8:08 PM
@Adám
13 11 14 11 5 9 12 6 5
 
thats cool
 
Indeed.
 
it seems like all the other numbers still show up though.....
 
Yes, we're not filtering, we're amending the existing list.
 
how would you filter the list
 
8:10 PM
We have a function, replicate which takes counts on the left and data on the right:
⍞←1 0 3 0⌿'abcd'
 
@Adám accc
 
So no we can ask which numbers are less than 5:
 
⍞←3 1 4 1 5 9 2 6 5<5
 
@Adám 1 1 1 1 0 0 1 0 0
 
8:11 PM
And use that as replication counts:
 
⋄ myNumbers←3 1 4 1 5 9 2 6 5 ⋄ ⎕←(myNumbers<5)⌿myNumbers
 
@Adám
3 1 4 1 2
 
there we go
okay
whats next to learn
 
Remember ⍳n?
⍞←⍳10
 
8:12 PM
@Adám 1 2 3 4 5 6 7 8 9 10
 
How might we go about making the first 10 odd numbers?
 
⋄ myNumbers←1 3 5 7 9 11 13 15 17 19 ⋄ ⎕←(myNumbers<5)⌿myNumbers
 
@ThePuzzlerThree
1 3
 
⋄ myNumbers←1 3 5 7 9 11 13 15 17 19 ⋄ ⎕←myNumbers
 
8:13 PM
@ThePuzzlerThree
1 3 5 7 9 11 13 15 17 19
 
Right, but say you wanted to generate the odd numbers instead of writing them by hand?
 
Well, can you think of how we could make the first even numbers, given ⍳10?
 
⋄ mynumbers←⍳10 ⋄ ⎕← but then what after this
 
8:16 PM
@ThePuzzlerThree
VALUE ERROR
 
dyalog stop!
 
How would you map the natural numbers to the even numbers?
 
i got to be honest i dont know how would we?
 
Let's try a different approach: What does it mean that a number is even?
 
ands in 0 2 4 6 or 8
ends*
divided by another even number=always whole
 
8:18 PM
No, that's not true.
4 is even. Divide it by 6 isn't whole.
 
But you're getting closer. Can you think of an actual property that even numbers have, which odd ones don't have? What can you do with them since they end in 0,2,4,…?
 
never mind.....
just tell me
 
What?
 
my brain is tired
 
8:21 PM
How about them being divisible by 2?
 
i was going to say that but didnt know if that was the right answer for our purposes
 
Which also means that if we multiply a natural number by 2, we're guaranteed to get an even number.
 
so multiply everything by 2
it will all be even
 
Exactly. Now can you put the pieces together to print me the first 10 even numbers?
(Don't be afraid to make a mistake — that's how to learn.)
 
⋄ myNumbers←1 3 5 7 9 11 13 15 17 19 ⋄ ⎕←(myNumbers*2)⌿myNumbers
 
8:23 PM
@ThePuzzlerThree
1 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 1
 
OK, a few issues here.
 
welp
i made them odd
 
1. We're not filtering.
2. You didn't start off with ⍳10
3. * is power, not multiply
 
can you post multiply
so i can copy and paste it
 
@ThePuzzlerThree You should have the language bar active. Copy-pasting will get tedious quickly.
 
8:26 PM
⋄ mynumbers←⍳10 ⋄ ⎕←(mynumbers×2)⌿myNumbers
 
@ThePuzzlerThree
VALUE ERROR
 
is for filtering. Don't do that.
 
⋄ mynumbers←⍳10 ⋄ ⎕←(mynumbers×2)
 
Nice! You don't even need any assignment:
 
8:27 PM
@ThePuzzlerThree
2 4 6 8 10 12 14 16 18 20
 
⍞←2×⍳10
 
@Adám 2 4 6 8 10 12 14 16 18 20
 
Now can you make the odd numbers?
 
8:28 PM
hold on like 1 minute getting a snack
ill ping u
 
ok
 
@Adám back
 
@ThePuzzlerThree OK, do the odd numbers.
 
just divide by 3 right?
⍞←3×⍳10
 
@ThePuzzlerThree 3 6 9 12 15 18 21 24 27 30
 
8:34 PM
.....
⍞←3.5×⍳10
 
@ThePuzzlerThree 3.5 7 10.5 14 17.5 21 24.5 28 31.5 35
 
:(
⍞←315×⍳10
 
@ThePuzzlerThree 315 630 945 1260 1575 1890 2205 2520 2835 3150
 
why am i doing this
 
@ThePuzzlerThree Uh, you do realise the distance from an odd number to the next one, no?
 
8:36 PM
2
 
Right, so 2×⍳10 is almost there. In what way do we need to modify these numbers to get the odd ones?
⍞←2×⍳10
 
@Adám 2 4 6 8 10 12 14 16 18 20
 
⍞←2×⍳10-1
 
@ThePuzzlerThree 2 4 6 8 10 12 14 16 18
 
8:37 PM
@ThePuzzlerThree Good, almost there, but remember the APL precedence rule!
Do you remember it?
 
OK, so try to fix your expression.
 
⍞←(2×⍳10)-1
 
@ThePuzzlerThree 1 3 5 7 9 11 13 15 17 19
 
8:38 PM
Very good!
 
You could also avoid the parenthesis by adding negative one:
⍞←¯1+2×⍳10
 
@Adám 1 3 5 7 9 11 13 15 17 19
 
hmm... ok
 
OK, now how would you get the first 10 squares?
 
8:40 PM
um
what u mean
 
1 4 9 16…
 
dont know.....
 
Think along the same lines as before. How can we modify the numbers 1 2 3 4 so we instead get 1 4 9 16?
Have you learned about raising a number to the power of another number?
 
Then you should recognise the series 1 4 9 16 25 36 49 64 81 100. Don't you?
@ThePuzzlerThree Wouldn't 1 2 3 4+1 give 2 3 4 5?
 
8:46 PM
yes
 
And do you recognise the series?
 
at 4:00 est have to go
no i dont
 
what are these numbers?
Would you prefer if we avoided mathematics in your introduction to APL?
 
OK. Let's talk about text then. You may have noticed that APL treats strings like number lists. This means you can address individual characters:
⍞←'mississippi'='i'
 
8:50 PM
@Adám 0 1 0 0 1 0 0 1 0 0 1
 
⍞←'yeet skadeet'='e'
 
@ThePuzzlerThree 0 1 1 0 0 0 0 0 0 1 1 0
 
In fact, you could put individual characters next to each other and they'd form a string too:
⍞←'miss' ≡ 'm' 'i' 's' 's'
 
@Adám 1
 
is a function that compares entire arguments instead of their elements.
 
8:52 PM
./
 
We can also treat strings as sets. Are you familiar with the ∊ symbol?
 
OK. It is fairly commonly used to mean "member of" or "element of" (hence the Greek letter ∊ "Epsilon" for Element):
⍞←'i'∊'mississippi'
 
@Adám 1
 
⍞←'hello world'∊'aeiou'
 
8:54 PM
@Adám 0 1 0 0 1 0 0 1 0 0 0
 
Can you think of a way to extract all the vowels from 'hello world'?
 
⍞←'hello world'∊'eoo'
 
@ThePuzzlerThree 0 1 0 0 1 0 0 1 0 0 0
 
Sure, but we'd want the result 'eoo'
 
⍞←'hello world'∊'eoo'
 
8:56 PM
@ThePuzzlerThree 0 1 0 0 1 0 0 1 0 0 0
 
That's the same thing. Duplicates in the right argument don't make a difference.
We want to filter 'hello world' so only vowels remain. Remember how you filtered before?
 
oh yeah
⎕←'hello world'⌿'eo'
 
@ThePuzzlerThree
DOMAIN ERROR
 
No, takes counts on its left, and the data to be modified on its right.
 
⎕←'eo'⌿'hello world'
 
8:59 PM
@ThePuzzlerThree
DOMAIN ERROR
 
(In fact, most dyadic APL functions take some kind of control array on their left and the main data on the right.)
@ThePuzzlerThree Notice this:
⍞←1 0 1⌿'abc'
 
@Adám ac
 
⍞←1 0 1 1 0 1 1 0 1 1 1⌿'hello world'
 
@ThePuzzlerThree hll wrld
 
You need to go now?
 
9:00 PM
@Adám yes
@Adám thank you so much
 
@ThePuzzlerThree So you got all the consonants. Maybe try the vowels when ready to continue?
 
@Adám have a good rest of the afternoon
 
@ThePuzzlerThree Ping me when convenient.
 
@Adám okay
 
 
2 hours later…
11:06 PM
can a dfn return a dfn?
 
@rcabaco No. If you want a class of related functions you may want to use an operator.
 
i wanted to return a projection or partially applied dfn
 
(Tradfns can return functions, but it is very unusual to do so.)
 
yes, my background is still biting
 
@rcabaco Well, you can curry one argument with .
 
11:10 PM
this will look ugly here
grid←{
     m←1⊃⍺
     n←2⊃⍺

     {
         a←1⊃⍺ ⋄ b←2⊃⍺ ⋄ c←3⊃⍺
         (+/a(m÷⍨b×1⊃⍵)(n÷⍨c×2⊃⍵)),(+/a(m÷⍨b×3⊃⍵)(n÷⍨c×4⊃⍵))
     }¨∘⍵
 }
i get a syntax error here
 
@rcabaco Should all be fixed now.
@rcabaco Press Ctrl+K to switch to monospace and preserve whitespace. You can still edit the message to do so.
 
@rcabaco The last statement is currently a function, not an array.
 
@rcabaco What will the other argument be?
 
eventually an array with the values of a, b and c
 
@rcabaco Btw, you can do (m n)←⍺ and (a b c)←⍺
 
11:13 PM
that's good to know :)
so what i have up there is not possible
 
@rcabaco So you want is for grid to give a monadic function which takes the a b c as argument?
 
yes
i'm trying to implement the grid function from here: github.com/alunny/functional-geometry-canvas/blob/master/…
 
@rcabaco Try:
grid←{
     (m n)←⍺⍺

     ⍵{
         (a b c)←⍺
         (+/a(m÷⍨b×1⊃⍵)(n÷⍨c×2⊃⍵)),(+/a(m÷⍨b×3⊃⍵)(n÷⍨c×4⊃⍵))
     }¨⍵⍵
 }
You'd use this as:
newfn←params1 grid params2
newfn a b c
 
@Adám I exactly thought the same thing.
 
can you explain the operators?
m and n are values
so are a b and c
 
11:17 PM
@rcabaco Have you used built-in APL operators?
 
ahhh
i see
no, but i've read about them
params1 is ⍺
params2 is ⍵
 
Well, ⍺⍺ and ⍵⍵.
E.g. the @ operator:
⍞←('X'@3)'abcdef'
 
@Adám abXdef
 
'X'@3 is a derived function which you could name:
⋄ myfn←'X'@3 ⋄ ⎕←myfn 'abcdef' ⋄ ⎕←myfn ⍳5
 
@Adám
abXdef
1 2 X 4 5
 
11:21 PM
a lambda
 
If we wanted to "wrap" @ in a dop (the operator equivalent of a dfn) it'd look like this: At←{(⍺⍺@⍵⍵)⍵}
So you can see that the ⍺⍺ and ⍵⍵ are the operands which are the parameters for generating a particular one of an infinite set of related functions.
 
so ⍺⍺ and ⍵⍵ are what is passed to the root/outer function
yes
 
No, I'd say that ⍺⍺ and ⍵⍵ are more "inner" than because of the calling syntax (⍺⍺ operator ⍵⍵) argument
the argument is being passed to the derived function, while the operands are being passed to the operator.
 
yes
 
The operator's code isn't actually run until the argument is given, at which point it says exactly what is to happen with both the operands and the argument.
 
11:25 PM
with root/outer i mean on the definition, not on the call site
 
I guess.
Another example is the Replace system operator ⎕R:
⍞←('c'⎕R'X')'abcdef'
 
@Adám abXdef
 
again here, 'c'⎕R'X' is a derived function which by itself isn't called at all until given an argument.
Operands of can be functions or arrays. Arguments can only be arrays.
 
in theory i think i understand it. lets see how i do in practice.
thank you once again for the help Adám
 
No problem. Any time.
 

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