« first day (1409 days earlier)      last day (1238 days later) » 

<droid3> your missing some bytes in your shortcode APLBot
<droid3> Anyway guys just getting into gnu APL . And was wondering on how you create function libraries for other APL programs to use
 
@ngn Perlis epigrams 85 Though the Chinese should adore APL, it's FORTRAN they put their money on. ;) cs.yale.edu/homes/perlis-alan/quotes.html
 
<droid3> right now i can just run commands at the interperter of apl
<droid3> is there anyway for libraries and code reuse
<droid3> also APL seems such a bitch to figure out how to call APL stuff from other languages
<droid3> its not like ruby calling c or c calling ruby , python , perl ,...etc stuff
<droid3> there got to be away to define functions in a seperate file and import them in ...in APL
<droid3> if APL would be a rich set theory based programming language but very limited to interface with other then itself in a single program
<droid3> Now i know it would be cheating if i compiler the interperter of gnu APL and just used extern c command
<droid3> So i would have imagine there got to be away to declare functions in another file and import them in APL.
<droid3> And if you can do that is there any header files to call APL from C or symbols from APL representing call an external function from another language
<droid3> I am stumped only with this language of all legacy languages i come across
<droid3> It bothering me for nothing more of sake of completeness rather then usefulness
<droid3> Because i am sorry if i offend anybody but APL is shit compared to mathematica, R , matlab ,..etc base mathematical languages
<droid3> I just find it kind of eye catching because it has weird symbols and shit apart from normal keyboard keys on your traditional keyboards
<droid3> Its like typing set theory
 
4:22 AM
droid3: Please don't compare APL to modern full-fledged mathematical systems, especially commercial ones (which include Mathematica and Matlab).
 
<moon-child> droid3: dyalog apl can interface with c#
 
APL is designed to have a small set of built-ins to do all kinds of computations, which is pretty much the opposite of a math system's goal.
 
<moon-child> droid3: also this fossies.org/linux/apl/doc/libapl.html for interfacing with gnu apl from c
<moon-child> droid3: 'APL is shit compared to [other things]' isn't particularly constructive. If you've encountered specific problems or pain points, then people may be able to help you with them; or people implementing APL and APL-like languages may find them useful as future directions. Just saying something is bad won't get you anywhere and won't make other people receptive to your concerns
<droid3> Ok ya that answers some of it aka call APL from C but how would you go the other way call C from APL ?
<moon-child> I'm not aware of anything in any of the APLs. J and k both have such facilities
<droid3> Ok forget that question for a second. Let me phrase it like this.
<droid3> First how do you make function library files for APL
 
For the ones who want to propose APL resources / tutorials for Machine Learning in APL, there are these papers from Master APLer Mike Powell on aplwiki. aplwiki.com/wiki/User:Mdpowell I am not sure whether there are other recent tutorials for ML in APL. Could be a good idea to gather them on APL wiki or Dyalog Resources/Documentation.
 
<droid3> like for example how can you put a dozen APL functions in a file and import it in the gnu interperter and call them
<droid3> Then the next step is asking you if there is any external keyword or symbol equivalent to call outside dll ,lib , .o files from APL function libraries
 
4:38 AM
Concerning APL readability discussion...I read old academic papers from the great APL educators in the 70s. It seems that non-CS students (students who had not yet learned a programming language) had no problem with the APL notation and using APL...
 
<moon-child> droid3: For GNU apl, I would take a look at gnu.org/software/apl/apl.html#File-Names-and-Paths. I expect that reading the rest of the manual will also answer some of your other questions
<droid3> Ok thank you so much now i am making progress. Apparently the delta designates start and end of a function
<droid3> For example
<droid3> I dont see in the docs anything about seperating function ,lamda functions ,...etc in a seperate file that you import into your interperter as need
<droid3> Like do you just throw all your functions in a txt file and some how import them into the gnu apl interperter ????
<moon-child> newer code will usually use the 'direct definition' style, which looks more like this: Average←{(+/⍵)÷≢⍵}
<moon-child> larger codebases are not super common. Though dyalog does have some namespacing capabilities
<droid3> ya i see there are 3 methods for creating function an the ∇-editor way is the one should be used
<droid3> fine with creating user defined functions more want to know how you put them all together in a seperate file and load them/unload them from the gnu apl interperter
<droid3> Also forget for a second breaking up APL function in seperate files
<droid3> Is there a APL keyword/symbol to allow one to call a external function or library from within the gnu apl interperter ?
<droid3> or can you only call APL from C not the other way around?
<droid3> is what i am wondering about
 
 
1 hour later…
6:19 AM
So I'm looking at the ⌹ implementation, and I can't figure out what line 24 is doing. gitlab.com/n9n/apl/-/commit/…
 
6:55 AM
(26{.65}.a."_)((26$}:|i:3),.i.@26)]}4 26$' '"_ works locally in J 901, but not in TIO. I can't figure out why...
Try it online! showing what it does locally.
 
7:58 AM
@Jonah TIO's J is old, no?
droid3: APLs tend to have ⎕NA to call C. APLcart result. Not sure if GNU APL has that.
 
@Adám GNU APL has a native interface, but it has a different API
It's quite simple to use, but you need to write glue code in C++.
You can look at my the SQL interface that I wrote for it. Check the GNU APL code in the file src/sql/apl-sqlite.cc. Look for the line that reads:
Token eval_AXB(const Value_P A, const Value_P X, const Value_P B)
 
8:52 AM
@EliasMårtenson as in, what's its purpose or what the syntax means?
 
@dzaima a loaded module exposes a single function, that is the entry point. It's called as such: `A FN[X] B`. Typically X is a number is this function dispatches on, and then you have a bunch of APL functions that exposes the interface to the user, like so:

∇Z←type SQL∆Connect arg
Z←type ⎕SQL[1] arg
 
? (i was replying about )
 
@dzaima Oh, you were asking about that.
I see.
My question is what that does? I'm guessing in evaluates the thing inside {} if n is greater than 1?
 
@EliasMårtenson yep, and returns it (and doesn't evaluate anything further down). The function is recursive, and this is the end condition
 
But the return value doesn't seem to be used anywhere?
 
9:00 AM
@EliasMårtenson wdym? it's called in L48, and the result variables (Q and R are used in L49)
 
But after the evaluation of line 24, won't it move on to line 25?
 
@EliasMårtenson no, it won't. A line of A:B is "if (A) return B;"
 
Oh I see.
OK, then it makes more sense.
 
there's a funny wrapping in {…}⍵ to allow for multiple statements in the return value because otherwise it can be just a single statement
 
It is my goal to have KAP implement this code with few, if any, hacky solutions, it will be a good test case to make sure I have all the important low-level features in place.
@dzaima I see. I figured it was something like that :-)
I don't currently have a return statement to allow for early returns from a function. I'm still torn if I want to provide it.
 
9:03 AM
@EliasMårtenson it's quite useful in writing recursive functions
 
True, but I already have a try/catch system that can be used for early exit.
I can wrap that stuff in a defsyntax and you'll have a "return" without making the language support it.
 
(fwiw in dzaima/APL, A:B is just if (A) B; and I have A:←B for if (A) return B;)
 
I'm thinking of using defsyntax, meaning it'll look like: if(A) { return B }
:-)
 
ngn
10:08 AM
@brgal perlis epigrams are great, always fun to re-read :)
@dzaima if you define : like that, the natural extension would be a:b:c as if(a){b;}else{c;} or even a full "cond": a:b:c:d:e ←→ a:b:(c:d:e)
 
@ngn I don't like that every other colon has a different meaning in that scheme. (Kind of like your complaint about APL/J trains.)
Every other expression would be a condition, ever other a conditional expression.
 
ngn
@Adám good point
 
@ngn imo a more natural extension would be that a:b:c is a short-circuiting b∧a:c. (and regardless it'd not consider it a good replacement of actual proper control flow)
 
With "guarded guards", a:b:c:d:e would be if(a&&b&&c&&d){e} where && terminates early.
That's extremely useful for stuff like ×⎕NC'⍺':⍺>5:'big alpha'
Also for debug:assert expensive check: so you can disable expensive sanity checks with debug←0
×⎕NC'debug':debug:assert expensive check: would allow you to not even define debug with the same effect as debug←0
 
<moon-child> how about lisp-style 'or', where a sequence of a:b:c:d:e returns the first truthy value?
 
10:21 AM
Not sure how that'd work. Can you elaborate?
 
moon-child: there's only one truthy value in APL - 1
 
@dzaima (Well, in Dyalog: 16 to be precise.)
 
(you could of course define there to be more, but you still couldn't early-return 0 from functions)
 
<moon-child> @Adám in lisp, (or a b) will evaluate to 'a' if a is truthy, otherwise to b
 
Yeah, that doesn't make much sense for APL.
 
10:23 AM
<moon-child> this maintains your truth tables for boolean inputs, but also lets you use arbitrary objects as inputs; so you can use that, for instance, to unwrap optional values
 
that works for an expression, but not really as a return system
 
Btw, moon-child, now you're here, I have two questions about the chat bot. Have a few mins?
 
<moon-child> it's quite late here, and I was about to go to bed. Sorry--can we talk tomorrow?
 
It'd probably end up being day after tomorrow for you, but no worries; nothing major or urgent.
What TZ are you in, if I may ask?
 
<moon-child> PST
 
10:28 AM
Oh dear.
 
ngn
10:44 AM
today's aoc was a nightmare. it took me hundreds of bytes. too ugly to share.
 
@ngn haha same
Had to use normal control statements
 
ngn
@Razetime guards are not great for control flow, but tradfns? - i wouldn't go that far :)
 
11:00 AM
I found a better regex...
 
@xpqz Never thought of making all the keywords into functions
that was really cool
 
Almost like macros in scheme...
 
11:16 AM
Inspired by @rak1507's idea from the other day.
 
ngn
@xpqz implementing ≤ in regex is perverse :)
 
12:17 PM
Not done today's AOC part 2 yet
It is so horrible
I absolutely hate this problem
I just used ≠.≠ in my code which looks like my face when I saw this problem
 
12:37 PM
@ngn Thank you!
I love my regexing after a long spell as a perl programmer in previous jobs.
Someone at work is speculating that this problem is a hint of things to come; the field names sound like asm instructions.
 
Oh no
I hope not
 
@ngn i think it can get down to ~270 char in k9
 
@Bubbler re: my earlier post Try it online!... Yes TIO's J is old, but I've successfully used the gerund form of Amend } on it before, so I was trying to figure out what feature it was failing on?
Also I tried each of the parts individually and they work.
 
@xpqz didn't look at your solution before posting mine, but stole the keywords idea from this chat
I like your regexes!
 
2:18 PM
Inner product is my new favourite operator
 
2:39 PM
@rak1507 How so?
@chrispsn can you show?
 
Now that I use it more there seems like there's a lot of opportunities for it
 
ngn
2:55 PM
@xpqz i belive it's this
 
I wish APL had dict literals :/
 
@xpqz Namespace literals are coming…
Namespaces can do everything (slower) that dicts can, and more.
 
'everything (slower) that dicts can' so not everything then
 
ngn
@Adám can they use arbitrary values as keys?
 
@ngn Ah, ok, I concede.
 
3:01 PM
@Adám can you use a string to lookup a value from a ⎕NS -- I've always understood the keys to be symbols? C.f mydict["stringval"]
 
@xpqz first you should wish APL had dicts
 
I've implemented my own dict tool now as a hashed vector for keys and a vector for vals -- stored as .keys and .vals in a ⎕NS. But if ⎕NS can do that directly in some way I've missed...
But k's approach sure is elegant.
 
What's the difference between (⎕S 3) and {⍺⎕S 3⊢⍵}?
 
@rak1507 the former is a monadic operator, the latter - a function
 
Is that why I can't do ⍬≢(⎕S 3) to test if a regex matches?
⍬≢{⍺⎕S 3⊢⍵} works fine
 
@rak1507 yep. It's syntactically the same as ⍬ + (∘3) which is ⍬ (+∘3)
 
Ah, is there any way around that?
 
ngn
@xpqz see also: dtm
 
@rak1507 no. That's often an issue with operators in tacit code
 
Ok
 
3:15 PM
@rak1507 This is my favourite SE message
 
What is
 
3:29 PM
I have a design question... Up until now, it's not been possible to define multi-adic functions (functions that can be both dyadic and monadic). What I'm doing is introducing a kin dof "undefined" value which can't be manipulated, and if a dyadic function is called monadically, then the left argument gets assigned the "undefined" value.
The question is: What syntax should be used to detect if a variable holds the "undefined" value?
It can't be a plain function, since functions evaluate its argument, and you can't evaluate "undefined".
Something like BOUNDP in Lisp.
 
@EliasMårtenson the way many ambivalent functions are defined is by assigning to , and the assignment isn't evaluated if is already defined. It's a good question on how to properly check for its existence (Dyalog has ×⎕NC'⍺' but that's pretty bad)
 
maybe some ⎕hasAlpha (maybe ⎕dy?) giving a boolean on whether it's given?
 
@dzaima Yes, that's what I'm thinking of
it's all very ugly though
 
and if going that route, you necessarily need some control flow in the function to conditionally use it
or you could go the BQN route where the special not-defined value means ommited value where it makes sense - e.g. {⍺-⍵}5 would call - monadically
 
3:38 PM
@dzaima That looks like a pretty interesting solution. I need to think about how that would actually work.
 
(BQN also has the ability to define multiple bodies for a function, so the monadic and dyadic case can be implemented completely separately - so something like {-⍵ ; ⍺+⍵}10 would be ¯10 and 4{-⍵ ; ⍺+⍵}10 would be 14)
 
For now, I decided to simply not bind the argument if it wasn't given
It works since I have a special syntax called isLocallyBound that checks if a variable is bound.
So for now it looks like: if(isLocallyBound('leftArgName)) { ... } else { ... }
 
@dzaima that's the behavior of ngn/apl
 
You can still access the global binding, which should cover all use cases
 
There are lots of ways to check if 𝕨 exists in BQN, but I'm not finding one that translates nicely to APL. On the other hand ⍺⊢default would still work to set a default value.
(1⊣𝕨)⊣0 works.
 
3:44 PM
Does BQN have imperative structures? Like if/then while, etc?
 
@EliasMårtenson No, and I'm not currently inclined to add them. See Control flow in BQN.
Example for (1⊣𝕨)⊣0.
 
ngn
4:18 PM
@dzaima @EliasMårtenson there's also monad⍠dyad to make an ambivalent function. i never liked "⍺←" syntax.
 
5:01 PM
What do you lot prefer, github.com/rak1507/Various-APL-Stuff/blob/master/… the first approach or the regex based one?
I think I prefer the regex based one, because it doesn't use format and it is more consistent
 
ngn
@rak1507 i like both. why do some of your regexes have ^$ and some don't?
 
Some of them cause errors, some don't, I'm too lazy to be consistent
I should probably stick them in all of them
or modify the r function to automatically use that
 
ngn
cmc: given two ints x and y that have the same number of digits, generate a short regex that matches only ints in the inclusive interval x..y
 
define short
 
That seemed easy until it wasnt'
 
ngn
5:11 PM
@rak1507 with length sublinear in x, i.e. below O(x)
 
:(
 
So given 104 and 109 it should match 104, 105, 106, 107, 108 and 109?
 
ngn
@xpqz yes, and no others
it was an obvious cmc to post after all the regex extravagance we've seen today :)
 
As you ask, presumably there's a clever way here.
 
ngn
i haven't solved it yet but it looks like it's gonna be fun
 
5:16 PM
Left to right, all equal digits can go verbatim into the regex.
As can the smaller of the first matching diverging pair.
So given 102 and 109, the regex would start ^102
No.
 
ngn
more like ^10[2-9]$
^(102|103|..|109)$ is forbidden as it's O(x)
(or should i say O(y-x)?)
 
So for 123456 and 127777, we want ^12[3-7][4-7][5-7][6-7]$
No wait
 
ngn
@xpqz that wouldn't match 123458
 
Hmm. Hard.
 
ngn
so, as you mentioned, the common prefix 12 can go out as-is. then we have three cases for the next digit: 3 or [456] or 7, so it should look something like ^12(3something|[456]\d\d\d|7something)$
 
5:46 PM
@Marshall Thanks for the interesting read.
 
 
3 hours later…
8:36 PM
@Adám, I've incorporated your suggestions in a follow-up :) 5ab5traction5.bearblog.dev/masks-for-array-access-in-apl
@ngn, @xpqz, not a pure regex, but in Raku this works: / \d+ % {123456..127777}/ ;)
 
ngn
@ab5tract that kills the joy of solving the challenge the hard way :) i have a ~340 byte solution in dyalog apl, by the way
 
@ngn :)
(there was a bug in my code anyway, constrain to range is ** not % in the regex syntax)
 
ngn
@rak1507 :i get an error in the regex-based part:
DOMAIN ERROR: Invalid output destination
M[19] r←⍬≢{⍵ ⎕S 3⍨'^(',⍺,')$'}
 
oh
uh
One minute
Oh I get that too, weird, I swear it worked before...
Oh I think I changed it, tested it, saw that it worked, and didn't realise that if you bind to a function and change the name, it doesn't change that behaviour
r←⍬≢{('^(',⍺,')$')⎕S 3⊢⍵} works though
 
ngn
8:54 PM
@rak1507 yes, sort of. it's close to my real answer, but not exactly equal to it.
ah, i found the error :)
 
What was the error?
 
ngn
@rak1507 byr: 200[12] -> 200[012]
 
Sorry, I don't know what that means
 
ngn
@rak1507 your regex for byr (birth year) should match the string "2000" too
 
Oh yeah, oops
I don't know why I didn't do 0-2
Do you know how to fix the invalid output destination error? preferably without using parentheses?
 
ngn
9:01 PM
@rak1507 i think you are mislead by the syntax. the ⍨ in A ⎕s 3⍨B doesn't swap A and B. this expression parses like (A ⎕s 3)⍨B because ⎕s is a dyadic operator.
 
Ahh makes sense thank you :)
 
ngn
so the ⍨ there makes it equivalent to B(A ⎕s 3)B and i'm not quite sure what that means
 
Is the easiest way to use parens for the left argument then?
 
ngn
@rak1507 probably
@rak1507 btw, r←≢{('^(',⍺,')$')⎕S 3⊢⍵} works too (without the )
⎕s here always returns either 0 or 1 matches, so we can just use the length (≢)
 
Oh yeah, I don't know why I didn't think of that, thank you! :)
I'll update my repo now
 
ngn
9:18 PM
@rak1507 another idea: if you change it to r←{≢('^(',⍺⍺,')$')⎕S 3⊢⍵}, you can remove all the -s
 
I like that
 
 
2 hours later…
10:53 PM
How do I remove history so when I open a clear workspace there's nothing above it? If that makes any sense
Ok I figured out that I could delete the log (not before accidentally deleting the session instead, oops!)
 

« first day (1409 days earlier)      last day (1238 days later) »