« first day (1460 days earlier)      last day (1177 days later) » 

5:32 AM
@dzaima Wait what? Dyalog has more features for ⍤? And I thought the nightmare was over.
 
6:21 AM
@EliasMårtenson Only for the symbol, not for Rank. It is overloaded as Atop: f⍤g is the same as (f g).
 
 
1 hour later…
7:50 AM
Announcement: APLcart now supports regex search; simply use leading and trailing slashes. Example.
 
 
4 hours later…
ngn
11:40 AM
@KamilaSzewczyk this is the way it works now. it's the k4 model (the most widely used k/q from kdb+), you use suffixes to specify type width in literals, e.g. 1 2 3j for 64bit, i for 32bit, h for 16bit, etc. this gives the programmer fine-grained control and slightly better performance because no overflow checks need to be done.
but it's also very tedious to program this way - you have to be constantly aware of the bit widths. so i decided to listen to the advice from aplers/bqners/k9ers and started refactoring my code for this model of ints overflowing into wider ints.
 
hmm, yeah, makes sense
 
ngn
i think dzaima explained the details well
 
well, you could check how rust does checked_add
and somehow reimplement it in C
and other checked functions
 
ngn
both clang and gcc have __builtin_add_overflow()
 
or that, yes
i don't have any other idea
 
11:43 AM
just embrace the overflowing who needs numbers bigger than 255 anyway lets be honest
 
ngn
so, it's a question of: 0. how to organize my arith code so it still fits on a page or two, 1. make sure it ends up vectorized properly in the binary, 2. deal with alignment issues - padding after the end of a vector shouldn't generate false positives for overflow
i haven't tried yet looking at the asm __builtin_add_overflow() produces in a vectorized loop. it would be interesting to see how it deals with the lack of an overflow flag for simd instructions.
 
You won't guess who's back.
sorry for not being there for a while, almost destroyed my drive a few times
 
welcome back
 
so have you installed RIDE, and if so are you annoyed by the keyboard thing? it'll give dzaima another link to add to his collection!
 
11:54 AM
naaah, actually haven't touched APL in a while, tho I have RIDE installed
tho you can take a look at what I've been working on recently with my Buddy
 
btw, @Konrad'Unrooted'Klawikowski i have a thing you may like
 
check dm's
 
12:59 PM
is there a smarter/better way of picking maximum of a n-dimensional matrix?
other than (⌈/)xN
fixpoint maybe?
 
@KamilaSzewczyk ⌈/,
 
ohh yeah i forgot about monadic ,
thanks
another small question: if i have a space separated matrix, with it's rows separated with newlines, how can i load it from a file for use with APL?
maybe regex replace of space to comma, and then ⎕CSV according to aplcart
 
You can tell ⎕CSV to use space as separator.
 
so 3 options - ⍎¨(⎕csv⍠'Separator' ' ') 'name'; ↑⍎¨ ,⎕csv'name'; ↑2∘⊃∘⎕vfi¨ ,⎕csv'name'
(heh, ⎕csv can be used for getting file lines if there are no commas)
oh, ⎕VFI is faster even for scalars
heh, {,⎕csv⍠'Separator'(⎕ucs 10)⊢⍵} adds a single trailing empty element (even if there's no trailing newline). Otherwise, that's a builtin for reading lines of a file :D
 
1:20 PM
(Still on my to-do list to ask Richard about ⎕NGETting one line at a time.)
@locks Hi. Interested in APL?
 
@Adám "file lines" query should show ⎕NGET file 1
 
@dzaima Indeed. Will do. Done.
 
@dzaima ↑2⊃∘⎕vfi¨⊃⎕NGET 'name' 1
also "string" would be a good keyword for ⎕ngets
 
@dzaima Really?
 
also aplwiki certs ended
 
1:24 PM
Yeah, we're aware. Luckily, http is available.
 
@Adám at least for the whole-file-as-single-string version. In java 11 the equivalent function is Files.readString(path)
(also ⎕nget'name' ends with a newline character regardless of if there was one‽)
 
@dzaima Ah, makes sense, as opposed to "lines" for the …1 version.
@dzaima No, only if there wasn't.
Maybe the …1 version should have "strings" in plural, though.
 
@Adám but why
 
@dzaima POSIX.
 
that's an excuse (a bad one) for writing a new line, but not for reading one where there isn't one
imo
 
1:30 PM
@Adám i mean i guess appending a newline character is valid undefined behavior, but still..
 
The idea is that ⎕NGET reads a text file and normalises it so you know what kinds of result you'll get.
 
@rak1507 +←1
 
@Adám I'd hope I'd get the contents of the text file!
 
@Adám this newline end thing is the only case where it actually removes information though
@Adám also the posix thing is about file lines, the ⎕nget without …1 shouldn't touch anything to do with lines!
also ⎕ngetting an empty file doesn't gives a plain '' so it's not even that there's always a trailing newline
 
@rak1507 That's not what it is for.
 
1:39 PM
@Adám ಠ_____ಠ
then what is the function for getting the contents of a file as a single string?
 
@Adám what is it for then
 
@dzaima Not true, it also removes BOM, encoding, variations in line endings.
@rak1507 Getting a text file ― i.e. you don't care about how it was stored, only about the text.
 
isn't that what I said?
 
No, you seemed to care if the file was POSIX compliant or not.
 
okay, so we'd need to read it as binary?
to get rid of that behavior?
 
1:41 PM
Yes, we have ⎕NREAD for that.
 
@Adám a newline at the end of the file is part of the text
 
@Adám "removes BOM" but it gives info on what the BOM was; didn't know about it normalizing lines though
 
@rak1507 According to POSIX, it only marks the ending of that line. You'd need two trailing newlines to have a trailing empty line.
 
that reminds me of a video I saw where something edited all lfs to crlfs... in an executable!
 
@Adám why does it even care about lines though?
 
1:43 PM
it?
 
oh right, it does normalization. imo normalization should be a different thing
@Adám ⎕nget without …1
@Adám afaict ⎕NREAD can't read unicode files
so is there really no function in Dyalog for reading a unicode-encoded file as a single string without it messing with it?
 
@dzaima True, but it is extremely simply to use ⎕UCS post read.
Basically, ⎕NGET is a convenience function for the most common sequence of ⎕NTIE, ⎕NGET, ⎕NREAD, ⎕UCS, and optionally some splitting.
 
@Adám so, 'UTF-8'⎕UCS 256|⎕NREAD('name'⎕NTIE 0)83 ¯1 for a non-broken file read.........
 
🤮
 
@dzaima Not non-broken, but non-normalised.
@dzaima What is it you're actually trying to achieve? Not having a trailing newline?
 
1:57 PM
@Adám being able to parse the file however i want to, without dyalog forcing its conventions on my specially-crafted files
 
@dzaima Sure, then you need a raw read. Even reading as Unicode is a type of auto-parsing.
 
@Adám Unicode is at least a standard for files of characters, and it's lossless
 
@dzaima So is a POSIX text file.
 
@Adám but it's not the standard I wanted to follow
 
So don't use the easy-to-use utility. If you want something very strict and specific, we have the building blocks so you can get exactly that.
⎕NREAD will even let you read chunks.
 
2:12 PM
@Adám hello :) indeed! decided to finally give it a go after seeing someone solving an advent of code problem on youtube
 
@Adám it's very annoying that that's named just "text file" as it's more of a "line file" than anything
 
@locks conor hoekstra?
 
@locks Cool. Have you started learning by yourself, or do you want help, tutoring, or pointers to learning materials?
@dzaima OK, but considering that terminology is used by a respected authority, I think it is fair that we call ⎕NGET "Read Text File".
 
@Adám ok sure..
 
2:25 PM
hello!
 
CMC: Foo takes a numeric vector as argument. Golf Foo:
∇ t←Foo t;i
  :For i :In 1↓⍳≢t
      t[i]←+/t[i-0 1]
  :EndFor
∇
 
2:52 PM
@locks I'd like to see that video, got a link handy?
 
yeah, it was this one by Conor youtube.com/watch?v=0RQFW6P1Tt0
 
@locks Thanks!
 
@Adám a two-byter?
 
@user41805 Yup.
 
@Adám I'm learning by myself. I have found some resources so far like the APL wiki, this chat, dyalog.tv and your presentation on APLcart! my background is JavaScript so everything is very alien to me and pointers are always welcome!
 
3:04 PM
@locks OK, if you have found this, then you are well on your way. I'd be happy to tutor you too, if you want.
 
@Adám looks like aplwiki has a certificate error?
 
2 hours ago, by Adám
Yeah, we're aware. Luckily, http is available.
 
ah
 
3:42 PM
@locks His solution: ×/({1↑⍸2020=∘.+⍨⍵}⌷⊢), mine: ×/⊢∩2020-⊢
 
4:06 PM
@rak1507 Yeah, I noticed. That's really clever.
 
RGS
@Adám No idea if this is relevant, but I use certbot certbot.eff.org to enable https on my site.
 
guys me and my Buddy came with a weird but a great idea
would it be possible to write a malware in APL? It would be crazy and really cool to look while cybersec people will try to reverse engineer it and read it 🥲
 
RGS
@RGS automatically and for free, those were the two key ideas that I should've included in the first message.
 
@Konrad'Unrooted'Klawikowski only if you pay dyalog 2% of all the cryptocurrency you make!
 
4:20 PM
@Konrad'Unrooted'Klawikowski dyalog allows packaging stuff as .exes
i think i wouldn't have much problem with it, but most researchers would cry :)
i used the same strategy for my x86 obfuscator, which is powered under the hood by brainfuck and malbolge
but apl seems like a decent language for the task
 
@KamilaSzewczyk imagine doing Oyabun implants with APL
 
anyways - i have a small question
i'm trying to solve projecteuler 12, and i came up with a few solutions
≢(∪⊢∨⍳)+/⍳1000, ≢(∪⊢∨⍳){2÷⍨⍵×⍵+1}1000, ×/1+1↓2 pco+/⍳1000
 
anything that uses (∪⊢∨⍳) will be obscenely slow
 
for checking the amount of divisors, the first two solutions use the semi-straightfoward solution
and the second one is using the "optimization", given that the amount of divisors is equal to the product of incremented exponents in a number's prime factorization
 
oh that's smart
 
4:23 PM
but it ends up being slower
somehow
 
weird
 
      dfns.cmpx '×/1+1↓2 pco +/⍳20' '≢(∪⊢∨⍳)+/⍳20'
  ×/1+1↓2 pco +/⍳20 → 1.6E¯5 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  ≢(∪⊢∨⍳)+/⍳20      → 2.8E¯6 | -83% ⎕⎕⎕⎕⎕⎕⎕
 
for small numbers sure but for large ones I reckon the pco method will be miles faster
 
hmm right i picked incorrect test data
but i have a different problem
i think this number may be millions or even more
and i'm running out of ws space quickly, and i can't test my solution on larger numbers
 
yeah
 
4:25 PM
@KamilaSzewczyk there you go
 
you can generate triangular numbers with +\⍳whatever
 
how do you import dfns into the current workspace?
instead of having to import them into dfns
 
@KamilaSzewczyk how are you doing it currently?
 
⎕CY 'dfns', )copy dfns pco to just copy pco
 
@rak1507 alternatively, 'pco'⎕cy'dfns'
 
4:27 PM
i used (⍎'dfns'⎕NS⍬).⎕CY 'dfns'
 
@KamilaSzewczyk ah, just copied from APLCart i assume
 
@dzaima that too
 
yes
so what am i supposed to do now?
i tried to look it up online how to increase the ws size
no results
 
Set MAXWS=2G
 
Question: What should the result of 1 ⌽∵ 0 0 1 be? (note, ∵ is the bitwise modifier operator). Since I haven't implementation rotation/shift yet, all the bitwise functions have been plain scalar function. But rotation brings that into question. The possible solutions are 8000000000000000 0 0 or 0 0 8000000000000000
 
4:29 PM
@KamilaSzewczyk set an environment var of MAXWS=…
 
In other words, should they shift across the array, or should it just be a plain scalar shift for each value independently?
 
@dzaima (for RIDE, open RIDE itself (not the quick-launch "dyalog" one), and add MAXWS=2G to the environment variables section)
 
@dzaima Doesn't have to be envvar. Can go on command line too: dyalog MAXWS=2G
 
@Adám that's still an environment variable, just a local one
 
@dzaima I don't think so. That'd only be on the left of the executable.
 
4:33 PM
another problem: i get a nonce error and the range has been exhausted
no results
 
⎕FR←1287
 
still
×/1+1↓2 pco+/⍳100000
 
@Adám oh, i thought that order was a mistake. dyalog also parses the envvars from its args?
 
@dzaima "Configuration parameters", but yeah.
 
@KamilaSzewczyk pco has a size limit of 2*32
 
4:34 PM
You can also use config files, the modern option…
 
@dzaima but i think i didn't exhaust it?
 
@KamilaSzewczyk (+/⍳100000)>2*32
 
oh true
hmmm
 
@KamilaSzewczyk replacing my much more stupid way of getting the factors with your way sort of works, but {×/1+1↓2 pco⍵} returns a 1 element vector not a scalar, try sticking a ⊃ in front and maybe that'll work?
alternatively use 2⌷ (1⌷ ⎕IO←0) instead of 1↓
 
absolutely
now it's okay
i got a domain error on iota underbar and i was about to do that
boxing is awesome, btw
 
4:38 PM
ah cool
yeah
 
ngn
triangular numbers are T(n) = n(n+1)/2. if you have the prime decompositions of n and n+1, you can easily combine them to get that of T(n)
 
okay, this works: +/⍳⊃⍸({500<⊃×/1+1↓2 pco+/⍳⍵}¨⍳20000)
 
+\⍳n is a better way of generating triangular nums
 
hmm oh i see, because it makes a sequence
my initial thought was to make this work like so, and then pray that APL somehow parallelizes this
i thought that doing this may force the entire thing to get computed step by step
i don't really know stuff so performance/inner workings tips would be appreciated
 
⊃{⍵/⍨500<{×/1+⊃⌽↓2pco ⍵}¨⍵}+\⍳15000 is my method
 
4:43 PM
are there any tuning methods for that?
i remember that you could set the parallel thread execution limit using some i-beam command
 
@KamilaSzewczyk Dyalog never does (and cannot do) thread-level parallelization. You need separate processes if you want to ever use >1 core
 
hmm, sad
i thought APL is parallelizable
 
@KamilaSzewczyk APL is, but Dyalog isn't. It does all kinds of funky things like stackless traversal for e.g. by writing pointers into arrays it's iterating through
 
didn't dyalog make some attempts before?
i could try co-dfns for my first time, it seems fun
 
@KamilaSzewczyk you'd probably need to rewrite pco for it or something then
 
4:47 PM
can't i copy the pco source and paste it in
 
ngn
trying to re-phrase my ignored hint: you only need to factor numbers up to 100000, not 100000*100000 :)
 
@KamilaSzewczyk I'm not sure it's compatible. but what do i know ¯\_(ツ)_/¯
 
what could stop that?
i may test it out later
 
@ngn I didn't ignore it, I just thought combining them wouldn't be as easy as you think, also my solution runs pretty fast so insert shrug emoji here
 
ngn
@rak1507 combining is literally just ⍺,⍵ without one instance of a 2
 
4:50 PM
@KamilaSzewczyk hm, i guess not much
 
@ngn yeah true, but then getting the exponents... is still easy but I see your point
 
ngn
@rak1507 exponents: ⊢∘≢⌸
 
yeah
I was thinking about trying to combine two exponent matrices like 2 pco gives rather than the actual prime factors, that is much easier
 
ngn
@rak1507 if only apl had proper dicts, that would be just +
 
yeah
 
ngn
4:54 PM
(and -1 at key 2, to knock off a factor of 2)
 
yep
 
ngn
sorry for the interruption, carry on with the multithreaded optimizations :)
 
 
1 hour later…
6:15 PM
@rak1507 @rak1507 could you go through your solution in words?
 
7:07 PM
×/⊢∩2020-⊢
×/           ⍝ the product of
  ⊢          ⍝ the numbers
   ∩         ⍝ intersect
    2020-⊢   ⍝ 2020 minus the numbers

if a, b are a pair that sum to 2020, b = 2020-a
 
7:31 PM
@rak1507 oohh that's clever! thank you for the explanation
 
np
 
7:47 PM
how am i supposed to convert a table like this:
┌──────────────────────────────────────────────────────────────────────────────
│3 7 1 0 7 2 8 7 5 3 3 9 0 2 1 0 2 7 9 8 7 9 7 9 9 8 2 2 0 8 3 7 5 9 0 2 4 6 5
├──────────────────────────────────────────────────────────────────────────────
│4 6 3 7 6 9 3 7 6 7 7 4 9 0 0 0 9 7 1 2 6 4 8 1 2 4 8 9 6 9 7 0 0 7 8 0 5 0 4
├──────────────────────────────────────────────────────────────────────────────
│7 4 3 2 4 9 8 6 1 9 9 5 2 4 7 4 1 0 5 9 4 7 4 2 3 3 3 0 9 5 1 3 0 5 8 1 2 3 7
├──────────────────────────────────────────────────────────────────────────────
into a matrix
 
↑?
 
... i totally forgot about it
thanks lol
 
np
 
Maybe ↑,
 
8:09 PM
@KamilaSzewczyk It may well be that you can avoid generating it like that to begin with.
 
8:31 PM
tips on optimizing this code? ⊃⍒(0∘{⍵=1:1+⍺⋄2|⍵:(1+⍺)∇1+3×⍵⋄(1+⍺)∇⍵÷2})¨⍳1000000
 
what does it do
oh collatz
 
ngn
problem #14, i can tell without looking :)
 
I used basically that method to generate a cache, and then use that cache for the rest
 
@ngn hahaha
 
8:35 PM
you could also try dfns.memo but I think that is slow
 
nice
@rak1507 oh yeah that would be smart
but APL doesn't support any hash-like structure OOTB
which is very sad
 
it has arrays which are all you need
(for this anyway)
 
yeah, for associations from a to n
this would be a bit smarter than this solution tbh
 
would certainly speed it up a bit
ngn probably has some totally different way that runs in K in 0.01 seconds or something
 
ngn
@rak1507 actually not for this one, though i've spent days trying to optimize it
 
8:41 PM
@rak1507 you'd need a big cache, though
 
@KamilaSzewczyk mine was 100K
 
i think i'd use memo, probably
 
ok gl lol
 
ngn
@ngn ≈20s (on this old slow avx-less netbook)
 
it ended up being much slower with memo
so i gave up on it lol
 
9:04 PM
c←1000000↑1 ⋄ ⊃⍒{f←{1+⍺⍺(⍵÷2)(1+3×⍵)[1+2|⍵]}⋄⍵≤≢c:∇{c[⍵]≠0:c[⍵]⋄⊢c[⍵]←⍺⍺ f ⍵}⍵⋄∇f ⍵}¨⍳1000000 seems fast-ish
horrible code I know
 
ngn
here's my attempt: h←1@0 1⊢0⍴⍨1+n←1e6⋄⊃⍒{×r←h⊃⍨n⌊⍵:r⋄⊢h[⍵×⍵<n]←1+∇(2|⍵)⊃(⍵÷2)(1+3×⍵)}¨⍳n
⎕io←0 as usual
 
mine is ⎕IO←1 just because it seemed to make it nicer
 
ngn
@rak1507 with n←1e5 (the problem asks for 1e6 but it's too slow for me) i measure: 6s for mine and 8s for yours
 
ngn
@dzaima confirmed
wrong ⎕io almost crashed my os :)
 
9:15 PM
:)
 
ngn
my k solution with n=1e5: 1.9s :P
 
@ngn and mine for 1e5 is?
 
ngn
@dzaima ≈3.3s
 
ngn
@ngn oh hang on, that wasn't fair because i run it with #!bash
 
9:22 PM
@dzaima (apparently this is a tiny bit more faster)
 
ngn
not much difference running the old one without a hashbang - 3.23s
@dzaima this one looks slower - 3.55
 
@ngn ¯\_(ツ)_/¯
 
ngn
it could be different for 1e6 though, and with avx
 
ngn
@dzaima 2.38s
 
9:33 PM
whoa!
 
ngn
i measured slightly better with i/⍨←a/⍨←1≠a⋄i a instead of (⊂1≠a)/¨i a
@dzaima now either something's wrong or that's much better
0.68s
 
@ngn yeah it does do that
 
ngn
wow. prev is unused and N can be inlined.
 
@ngn yeah, prev didn't work out
@dzaima (cleaned up)
 
9:40 PM
@dzaima
 
@Adám true
 
ngn
@Adám not golfing
 
Still, also ÷2
 
@Adám (1+5×m←2|a)×a÷2 would go into floats if that's what you meant
 
@dzaima No, (a×1+5×m←2|a)÷2
 
@pitr @rak1507 @KamilaSzewczyk @RGS This week, I'm intending to experiment/prototype a new system for loading code on demand. Can we find a time that fits everyone?
 
Probably after school for me so 4 pm+ GMT?
or earlier on thursdays because that finishes at 1 ish
or at any other time really, who needs to pay attention in online lessons anyway...
 
Noted. Let's see what the others say.
 
ngn
@dzaima not faster for me
 
@ngn it's like a 20% improvement for me for 1e6
 
ngn
9:55 PM
ok, it's time to try translating your clever algorithm to k
 
@ngn does it have unique mask?
 
ngn
@dzaima no, that looks like it's gonna be the hardest part
@dzaima you'd be surprised if you saw how my "unique" works - it sorts first :)
 
RGS
@Adám I'm up for this, but why am I being pinged? Did I sign up for something I don't remember? :P
 
RGS
Mon, Tue or Wed for me, after 4pm like rak said is fine.
@dzaima I don't think this is the same thing,is it? What you linked is about an "open session", which doesn't look the same as a prototype to load code on demand.
 
10:05 PM
@RGS as far as I understood, Adám is intending to host an "open session" about that load on demand thing
 
That's how I understood it too
 
RGS
Nvm,I didn't realise Adam was replying to pitr's message. I guess your interpretation is correct.
@Adám may I suggest a doodle poll?
 
Not really necessary, as we've already narrowed it down to Tuesday or Wednesday at 16:00 UTC.
 
10:42 PM
for those not in the CGCC discord, here's an art piece
 
@dzaima What are these, most common off-topic conversations?
 
@Adám :)
 
Just have to convince all the Abrahamic religions to use the BQN versions instead.
 
@Marshall No chance in… oh wait:
5
A: PTIJ: What does halacha say about choosing a computer language?

AdámIt depends of course on what kind of program you're trying to write. If you're programming orbital mechanics or anything else related to astronomy, then Hashem recommends Haskell, as it says in the piyut (liturgical poem) called Keil adon: טוֹבִים מְאוֹרוֹת שֶׁבָּרָא אֱלֺהֵינוּ יְצָרָם בְּד...

 
10:59 PM
Hahaha
 
ngn
it's "purim torah" :)
(deliberately bad interpretations of scriptures, made for a specific holiday)
@dzaima i got to 2x the time your solution. i can't go further because i don't have narrower types yet.
 
ngn
11:51 PM
is there a simple way to detect multiplication overflows, similar to (x^r)&(y^r)?
 
@ngn I think you might have to actually compute the upper half-result. Vector multiplication in x86 is horrible. You might actually want to do each type separately by hand.
 
ngn
@Marshall thanks. my hopes for treating arith in a uniform way are fading :|
 

« first day (1460 days earlier)      last day (1177 days later) »