« first day (1072 days earlier)      last day (1876 days later) » 

00:12
@Adám Here is bit-width-agnostic 2's-complement bitwise arithmetic.
 
7 hours later…
06:45
⍞←∘.⌽⍨⍳3
@voidhawk 1 2 3
Oh right
⍞←∘.⌽∘⊂⍨⍳3
@voidhawk  2 3 1  3 1 2  1 2 3
 
2 hours later…
08:35
Just almost got a free lunch because dfns is weird.
 
2 hours later…
10:26
APL primitives little thinked because it is easier doing
a+b when a and b are numeric array even different lenght
define + in the way
1 + 1 2 3 return 1 2 4
1 1 + 1 2 3 return 1 3 4
and it is easy doing actual 1+1 2 3 in apl as
((≢a)⍴1)+1 2 3 return 2 3 4
easier than
in a+b a and b integer array different size
((≢a)⍴1)+a←1 2 3 return 2 3 4
easier than
in a+b a and b integer array different size
APL primitives little thinked because it is easier doing
a+b when a and b are numeric array even different lenght
define + in the way
1 + 1 2 3 return 1 2 4
1 1 + 1 2 3 return 1 3 4
and it is easy doing actual 1+1 2 3 in apl as
((≢a)⍴1)+a←1 2 3 return 2 3 4
easier than
in a+b a and b integer array different size
APL primitives little thinked because it is easier doing
a+b when a and b are numeric array even different lenght
define + in the way
1 + 1 2 3 return 1 2 4
1 1 + 1 2 3 return 1 3 4
and it is easy doing actual 1+1 2 3 in apl as
((≢a)⍴1)+a←1 2 3 return 2 3 4
easier than
in a+b a and b integer array different size
when the size is different all is filled form zeros
10:51
@RosLuP Sure, filling with zeros can make sense for + and -, because that's their identity element. However, you probably wouldn't want 1 2×1 2 3 to give 1 4 0, or 1 2 3÷1 2 to error. And what about , should it error on uneven length? If so then + and are different, which contradict the current definition of +; that it pervades.
 
3 hours later…
13:39
@Bubbler Why "100-200?"?
14:30
Anyone here for the APL Cultivation session?
Hello, I'm here for the session.
@AnandChitipothu Ah, cool.
I guess we can get started, and then others can join if and when they show.
Do you have anything in particular you'd like to go through? Otherwise, I was thinking we could go deeper into high-rank (many-dimensional) arrays and how to apply functions to them.
I don't have anything in mind. Lets go with what you suggested.
14:41
OK, so we have been dealing mostly with vectors (lists) so far, being able to write them as literals like 1 2 3 and 'abc'.
One of the ways to create a higher-rank array is to reshape a vector to a desired shape.
For that we use (Greek Rho for Reshape):
⎕←2 3⍴'abcdef'
@Adám
abc
def
Yes, I've done that earlier. I guess in solving game of life and even in one of the earlier sessions here.
Right. Now ⎕AVU is a long built-in list of semi-random natural numbers, convenient for trying things out:
⎕←2 3 4⍴⎕AVU
@Adám
  0   8   10   13
 32  12    6    7
 27   9 9014  619

 37  39 9082 9077
 95  97   98   99
100 101  102  103
APL shows a blank line to delimit the 2 layers of this 3D array, each of which have 3 rows and 4 columns.
@AnandChitipothu Do you remember how to sort in APL?
14:45
I like using the following setting in dyalog APL when working with mutli-dimentional arrays.
]boxing on -style=max
⎕←⎕SE.display 2 3 4⍴⎕AVU
@Adám
┌┌→────────────────┐
↓↓  0   8   10   13│
││ 32  12    6    7│
││ 27   9 9014  619│
││                 │
││ 37  39 9082 9077│
││ 95  97   98   99│
││100 101  102  103│
└└~────────────────┘
what is Quad AVU (i'm assuming that is how it is read).
Where do I find help for that?
@AnandChitipothu It, as seen here, does show an indication of every axis, but the actual display of data is the same inside the borders.
@AnandChitipothu You can always hit F1 on it (in your local APL), or:
]help ⎕AVU
14:48
@AnandChitipothu However, it is really uninteresting. It is the code page for compatibility with pre-Unicode APL.
So we can sort using the tacit function (⊂∘⍋⌷⊢). Do you want an explanation of it?
I'm trying to generate random numbers in a different way other than using ⎕AVU
@AnandChitipothu Just use ? but for what we'll do here, we want to use the same data each time, and the bot cannot remember well.
got it. Lets go with what you have.
trying to decipher tacit.
@AnandChitipothu You could reset the seed for a RNG each time:
⍞←⎕←?⍨100 ⊣ ⎕RL←1
@Adám 2 85 98 72 32 60 70 38 17 44 64 66 30 59 100 99 20 69 29 67 6 68 75 24 56 41 89 21 53 15 23 91 78 84 92 86 14 34 81 79 95 94 11 83 63 43 45 52 12 88 16 49 65 31 57 8 73 76 55 4 42 3 9 35 1 18 46 19 71 25 37 90 48 82 7 80 26 47 22 40 33 93 36 27 13 77 74 58 28 96 54 97 62 61 39 87 51 10 5 50
14:53
⍞←⎕←?⍨10 ⊣ ⎕RL←1
@Adám 2 5 10 8 4 6 9 3 1 7
⍞←⎕←?⍨100 ⊣ ⎕RL←1
@Adám 2 85 98 72 32 60 70 38 17 44 64 66 30 59 100 99 20 69 29 67 6 68 75 24 56 41 89 21 53 15 23 91 78 84 92 86 14 34 81 79 95 94 11 83 63 43 45 52 12 88 16 49 65 31 57 8 73 76 55 4 42 3 9 35 1 18 46 19 71 25 37 90 48 82 7 80 26 47 22 40 33 93 36 27 13 77 74 58 28 96 54 97 62 61 39 87 51 10 5 50
But ⎕AVU is fine for now.
So the sorting function says ⊂∘⍋ the enclosed grade indexes into the argument.
Because i j k⌷data is like data[i;j;k].
But we only want an i so we can reorder along the leading dimension. That's why i needs to be enclosed.
(⊂∘⍋⌷⊢) is equivalent to {(⊂⍋⍵)⌷⍵}
14:57
I'm trying to understand each symbol.
is the right (and in this case only) argument, pointing its finger to the right.
is the index function which is [ and ] printed on top of each other.
⍞←⍋ 10 ⍴ ⎕AVU
@AnandChitipothu 1 7 8 2 10 3 6 4 9 5
⍞←10 ⍴ ⎕AVU
@AnandChitipothu 0 8 10 13 32 12 6 7 27 9
14:59
is grade up (like an airplane going up), it gives the indices that would sort the argument.
is enclose, packages its argument into a scalar.
why are we enclosing?
Because allows selection along each axis:
⎕←2 3 4⍴⎕AVU ⋄ ⎕←2 1 3⌷⎕AVU
@Adám
  0   8   10   13
 32  12    6    7
 27   9 9014  619

 37  39 9082 9077
 95  97   98   99
100 101  102  103
LENGTH ERROR
Sorry:
⎕←2 1 3⌷2 3 4⍴⎕AVU ⋄ ⎕←(2 3 4⍴⎕AVU)[2;1;3]
@Adám
9082
9082
15:01
See the correspondence between i j k⌷data and data[i;j;k]?
⍞←(⊂∘⍋⌷⊢) 4 5 ⍴ ⎕AVU
@AnandChitipothu    0   8 10 13   32
You need ⎕← to display multiple lines:
⎕←(⊂∘⍋⌷⊢) 4 5 ⍴ ⎕AVU
@Adám
   0   8 10 13   32
  12   6  7 27    9
9014 619 37 39 9082
9077  95 97 98   99
Compare to the unsorted:
⎕←4 5 ⍴ ⎕AVU
15:03
@Adám
   0   8 10 13   32
  12   6  7 27    9
9014 619 37 39 9082
9077  95 97 98   99
Heh, in this case it was already sorted.
both are same. it is not sorting.
@AnandChitipothu It is sorted. Let's try this one instead:
⎕←3 4⍴⎕AVU
@Adám
 0  8   10  13
32 12    6   7
27  9 9014 619
⎕←(⊂∘⍋⌷⊢)3 4⍴⎕AVU
15:04
@Adám
 0  8   10  13
27  9 9014 619
32 12    6   7
Noticed that the last two rows swapped position.
yes. Is it sorting based on the first element only? (the first column)
No, but the major cells (which in a matrix are the rows) are sorted lexicographically. Since they differ in the first position, there's no need to look further.
⎕←(⊂∘⍋⌷⊢)'aacc' 'baab' 'aabc'
@Adám
┌────┬────┬────┐
│aabc│aacc│baab│
└────┴────┴────┘
⎕←(⊂∘⍋⌷⊢)3 4⍴'aaccbaabaabc'
15:06
@Adám
aabc
aacc
baab
Here it had to look at the third element of each row to sort the two that begin with 'aa'.
@Adám got it.
Now by defining our functions in terms of the leading axis, like we've done with the sorting here, we can use the "Rank" operator to tell APL which sub-arrays we want the function to be applied to.
Could you please explain:

(⊂∘⍋⌷⊢) is equivalent to {(⊂⍋⍵)⌷⍵}
For sure. The curly braces makes an "explicit" (as in it does mention its argument ) function.
The tacit function (in round parenthesis) uses the train syntax where the first and third function (counting from the right) are applied directly to the argument, while the second function is applied between their results.
15:10
I understood how {(⊂⍋⍵)⌷⍵} is working. I'm confused about how ⊢ which gives the right element is doing the magic.
We have a rule that for three functions f g h and the array Y the syntax (f g h)Y means (f Y) g (h Y)
@AnandChitipothu is simply a no-op function applied to the argument, which of course gives the argument.
we are using ⊢ in the monadic form, which is identity function.
got it. Thanks!
can we try another train function before we move on?
Yes. Maybe I should have said that (⊂∘⍋⌷⊢) is equivalent to {(⊂∘⍋⍵)⌷(⊢⍵)}
which in turn can be simplified to {(⊂⍋⍵)⌷⍵}
15:13
That makes it pretty clear.
Let's do average (arithmetic mean): (+⌿÷≢) (but the last character inside the parenthesis may render funny if you use Chrome. It should be with / overlay)
I'm on firefox and it looks fine
OK, good. It is the sum +⌿ divided by ÷ the tally
Exercise: Can you give me the equivalent explicit function?
let me think...
{(+⌿⍵)÷(≢⍵)}
Yes, very good.
How about the other direction. Say we have a "normalise" function {⍵÷+⌿⍵}. Can you make that into a train?
15:18
thinking...
what is the function to swap arguments?
@AnandChitipothu The operator: X f⍨ Y is Y f X but you shouldn't need it here.
Got it.

⎕←(⊢÷+⌿) 1 2 3
⎕←(⊢÷+⌿) 1 2 3
@AnandChitipothu
0.1666666667 0.3333333333 0.5
Right!
I think I got a hang of trains. Thanks!
15:23
Of course.
Now lets go back to
⎕←2 3 4⍴⎕AVU
@Adám
  0   8   10   13
 32  12    6    7
 27   9 9014  619

 37  39 9082 9077
 95  97   98   99
100 101  102  103
The whole array has rank 3. The layers have rank 2, and the rows have rank 1.
Now while the array as a whole is sorted, the individual layers are not (well, the first layer isn't).
Yes. If sort the first layer, the last two rows get swapped.
We can take our sorting function and apply it rank-2-wise:
Oops.
@Adám
SYNTAX ERROR
15:26
⎕←(⊂∘⍋⌷⊢)⍤2⊢2 3 4⍴⎕AVU
@Adám
  0   8   10   13
 27   9 9014  619
 32  12    6    7

 37  39 9082 9077
 95  97   98   99
100 101  102  103
is a dyadic operator which takes a function on its left, and on the right it takes a specification of which sub-arrays we want to apply that function to.
The extra to the right of ⍤2 is there to separate the 2 from 2 3 4 so they don't form the 4-element vector 2 2 3 4.
Some of the rows are not sorted either (last two rows of first layer, and first row of second layer).
Task: instead of sorting the layers' rows, sort all six rows instead.
Let me try..
⎕←(⊂∘⍋⌷⊢)⍤1⊢2 3 4⍴⎕AVU
@AnandChitipothu
  0   8   10   13
  6   7   12   32
  9  27  619 9014

 37  39 9077 9082
 95  97   98   99
100 101  102  103
Exactly.
The sorting function preserves the shape of the data it sorts. But some functions change the shape. That's not a problem either. Let's e.g. drop the first layer:
⎕←1↓2 3 4⍴⎕AVU ⋄ ⎕←⍴1↓2 3 4⍴⎕AVU
15:33
@Adám
 37  39 9082 9077
 95  97   98   99
100 101  102  103
1 3 4
Notice that the resulting shape is 1 3 4 not 3 4. We still have the same number of axes, we just shortened the array along one axis.
Task: Drop the first row from each layer.
Do we need to do the reverse of ⊂ if we just want 3 4?
@AnandChitipothu No, that wouldn't work. But would do it: 1⌷1↓2 3 4⍴⎕AVU
Now can you drop one row from each layer?
15:37
trying...
I tried with each ¨, but that didn't work.
@AnandChitipothu No, use like before. Think about what we want to see. The right argument should have which rank?
⎕←1↓⍤2⊢2 3 4⍴⎕AV
@AnandChitipothu


	⌶ɫ

_abc
defg
⎕←1↓⍤2⊢2 3 4⍴⎕AVU
@AnandChitipothu
 32  12    6   7
 27   9 9014 619

 95  97   98  99
100 101  102 103
15:43
Yup.
And if we want to remove the first column (=element) from each row, we'd use 1↓⍤1
Let's say we have a table like:
⎕←4 3⍴⎕AVU
@Adám
 0    8  10
13   32  12
 6    7  27
 9 9014 619
And now we want to increase these values by some multipliers. The first row should be multiplied by 3, the second by 1, the third by 4 and the last one by 1.
In other words, we want 3 1 4 1×4 3⍴⎕AVU
Bu we can't just do the multiplication, as you can't multiply a vector by a matrix:
⎕←3 1 4 1×4 3⍴⎕AVU
@Adám
RANK ERROR
help on ⍤ has an example.
Instead, we need to think about what we want × to see.
Yeah, so we say that on the left, we want × to see scalars (individual numbers) which have rank 0 and on the right we want the rows which have rank 1:
⎕←3 1 4 1×⍤0 1⊢4 3⍴⎕AVU
15:49
@Adám
 0   24  30
13   32  12
24   28 108
 9 9014 619
Is it possible to pass an array of more than 2 elements as argument to ⍤?
hello
how are you all?
Hello @ThePuzzlerThree.
@AnandChitipothu As rank-specifying operand? Yes, it can take up to three which means (monadic,left,right).
@ThePuzzlerThree Very well. We're in the middle of a APL learning session. Interested in APL?
im here to learn what it actually is from a human and not wikipedia
15:53
@Adám can you please show me an example?
@ThePuzzlerThree OK, can you hang around for 10 mins until the lesson is over, and I'll give you a personalised intro?
@AnandChitipothu Yes. Give me a min.
mension me so i get the notification when u r ready
Of course.
15:54
i cant spell
@AnandChitipothu OK, while a bit contrived, look at this:
⎕←⊖2 3 4⍴⎕AVU
@Adám
 37  39 9082 9077
 95  97   98   99
100 101  102  103

  0   8   10   13
 32  12    6    7
 27   9 9014  619
So this flips the array upside down. We could also give it rank 3 to produce the same result (as the array has rank 3):
⎕←⊖⍤3⊢2 3 4⍴⎕AVU
@Adám
 37  39 9082 9077
 95  97   98   99
100 101  102  103

  0   8   10   13
 32  12    6    7
 27   9 9014  619
However, dyadic is rotate with the left argument specifying the number of steps. When given a vector on the left and a matrix on the right, it rotates (cyclically) each column of the matrix by the specified amount:
⎕←0 1 0 1⊖2 3⍴⎕AVU
15:57
@Adám
LENGTH ERROR
oops
⎕←0 1 0 1⊖3 4⍴⎕AVU
@Adám
 0 12   10   7
32  9    6 619
27  8 9014  13
⎕←3 4⍴⎕AVU
@AnandChitipothu
 0  8   10  13
32 12    6   7
27  9 9014 619
Notice that columns 2 and 4 were rotated one step.
We could do this for each layer of our rank-3 array:
15:59
interesting...
is dyalog apl a bot?
⎕←0 1 0 1⊖⍤1 2⊢3 4⍴⎕AVU
@Adám
 0 12   10   7
32  9    6 619
27  8 9014  13
@ThePuzzlerThree Yes.
15:59
oops again
⎕←0 1 0 1⊖⍤1 2⊢2 3 4⍴⎕AVU
@Adám
  0  12   10    7
 32   9    6  619
 27   8 9014   13

 37  97 9082   99
 95 101   98  103
100  39  102 9077
Now we can define single function which, when applied monadically flips the entire array, but when used dyadically it uses a vector on the left to rotate the layers on the right: ⊖⍤3 1 2
⎕←⊖⍤3 1 2⊢2 3 4⍴⎕AVU
@Adám
 37  39 9082 9077
 95  97   98   99
100 101  102  103

  0   8   10   13
 32  12    6    7
 27   9 9014  619
⎕←0 1 0 1⊖⍤3 1 2⊢2 3 4⍴⎕AVU
@Adám
  0  12   10    7
 32   9    6  619
 27   8 9014   13

 37  97 9082   99
 95 101   98  103
100  39  102 9077
16:02
@AnandChitipothu Makes sense?
Time's up for this session, but I suggest we continue in 2-3 weeks with more advanced usages of .
am i in the right shell if i type one and => 1 appears?
@ThePuzzlerThree No. You seek to use an APL "shell" (REPL)?
.....
i use python so i call it that
@ThePuzzlerThree Have you downloaded an APL system?
Thanks a lot @Adám. Quite enlightening session. I'm still trying to understand the monadic use.
@AnandChitipothu Go experiment! If you are exploring monadic use, try using the function as it will enclose what it sees, showing you what whichever function you'd use instead would see.
Thanks. I'll continue to experiment. Looking forward for the next session. I'll try to come better prepared next time.
should i download one?
@ThePuzzlerThree Well, it is highly unlikely that APL comes pre-installed on your machine. Go here to download one, or try the pared down system online at TryAPL.org, or use the bot here.
i can use the bot for now
16:09
@ThePuzzlerThree I can give you a quick overview of what APL is now, and if that sounds interesting to you, maybe we can plan for a more full intro later.
@ThePuzzlerThree If so, you probably want to use this so you can type APL characters.
okay
opened in browser
@ThePuzzlerThree APL is a very special programming language. It is based on extensions and harmonisations of traditional mathematics such that mathematics becomes powerful enough to perform general-purpose programming tasks.
what are some of the things i can do with APL?
16:12
Basically anything you can do in any programming language.
It is especially used by data scientists and within finance, because it is very math-friendly.
any recommended sites for learning?
⎕←0 1 0 1⊖⍤3 1 2⊢2 3 4⍴⎕AVU
@ThePuzzlerThree
  0  12   10    7
 32   9    6  619
 27   8 9014   13

 37  97 9082   99
 95 101   98  103
100  39  102 9077
16:14
@ThePuzzlerThree I suggest you look at the appropriate section of the learning resources on the APL Wiki.
Can I ask you what your background is?
?
my programing backround?
Yes, and maybe your field(s) if programming isn't your main thing.
i am a high school student that loves to program although i study graphic design. programming is just for fun.
i mainly make chatbots
16:18
OK, cool. And you use Python normally?
Has it ever happened to you that you by mistake used a reserved word as a variable or function name?
One of the features I like the most about APL is that it has no reserved words. None.
that will be useful
then again, does it have any words?
16:21
All words are for the programmer to use freely.
All core built-in functionality uses various mathematical symbols (and a few Greek letters).
so thats what that website is for
Special non-core system functionality uses a prefix character to avoid making any reserved words.
@ThePuzzlerThree The Wiki?
16:24
Well, that's to help people to be able to type APL characters in a browser. However, installing an APL system proper will also install a real keyboard layout, enabling typing APL characters in all applications.
got it
to program i usually use repl.it
repl.it
why wont the link show up!
If you type the full url with http://, it will. Alternatively, use markdown: [text](url)
There's an APL on repl.it too.
yeah
almost any programming language you can think of is on there
how should i start
;
I don't think so. What does it have, like 50 or so?
@ThePuzzlerThree You'd need that language bar installed (bookmarked) to type APl on repl.it too, btw.
only 40
but still
yep
i bookmarked it
16:28
TIO has almost 700. But it doesn't feature interactive REPL functionality. Only static scripts.
i use repl becuase of that
i also cant run my code?
PYTHON TURTLE IS NPT ON THERE!!! :(
@ThePuzzlerThree While I don't have time to give you a full personalised intro this minute, I'd be happy to do so asap. When are your availabilities?
okay
when is easy for you
I mean, time zone and school...
I can probably be here in say 4 hours.
now that i think about it, how does 3:15 pm eastern time tommorow work?
16:33
@ThePuzzlerThree That won't work for me. Next chance after tonight would be Saturday afternoon EST.
exact time?
on saturday about 2 is when i can come on
2 pm EST (7pm UTC) is good for me. Let's meet here then.
okay
thank you
;)
If you can't wait to get started, I suggest looking at that APL Wiki page or the "APL Basics" lessons on the Learn tab of tryapl.org
okay
⎕←1
16:36
@ThePuzzlerThree
1
⎕←0 1 0
@ThePuzzlerThree
0 1 0
⎕←0 1 0 1⊖⍤1
⎕←0 1 0 1⊖⍤3 1 2⊢2 3 4⍴⎕AVU
@ThePuzzlerThree
  0  12   10    7
 32   9    6  619
 27   8 9014   13

 37  97 9082   99
 95 101   98  103
100  39  102 9077
adam if you r still on im out
see you on sat.
16:38
See you!
 
6 hours later…
22:57
2+2 ⋄ 3+3
⎕←2+2
@ThePuzzlerThree
4
23:21
@Adám For the 100-200?, while it is technically 200 (I guess), it felt like I put too little effort on the challenge.
But on second thought, finding the right shortcut is also part of code golf, so I changed it to simply 200.
@ThePuzzlerThree Hi.
how are you?
⎕←1+1 ⋄ 2+2
@ThePuzzlerThree
2
Just fine.
23:32
you are a code golfer?
Yes, mainly in APL these days.
yeah
i want to learn how to do code golf
is it possible in python?
CGCC has lots of Python golfers.
cool
any reccomended websites to start learning how to code golf?
257
Q: Tips for golfing in Python

marcogWhat general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is not an answer). Please post one tip per answer.

23:35
the problem is that i dont know what code golf is....
Recommended websites: definitely here (CGCC).
Usual workflow is to build a working solution, and then shorten it using various techniques.
okay
can i enter it in the bot here?
basically i solve an equation in the shortest way possible
correct?
its easily 10pm for adam right now
You solve various tasks, not just equation.
oh okay
on the stack exchange, you post code golf probllems as well?
not just questions about it?
On this site, the questions are mostly challenges (tasks).
23:40
okay
thx for the info
Just pick a task you like, solve it, shorten it as much as you can, and post it as an answer.
got it
have a sample task for me?
If your code can be shortened further, other golfers will help you in the comment.
I can't recommend a specific one. Instead, just look around the list of tasks, pick one and see how things work.

« first day (1072 days earlier)      last day (1876 days later) »