« first day (750 days earlier)      last day (1912 days later) » 

3:27 AM
I just got dyalog up and running -- I'm having a much better experience with it than with GNU
 
 
2 hours later…
5:04 AM
I'm pretty sure it's incorrect, but here's my toy GoL implementation:
      ]defs
offsets ← {{⍵∘.,⍵}(⌈⍵÷2)-⍨⍳⍵}
    rot ← {(⍺[2])⌽(⍵⊖⍨⍺[1])}
   rots ← {(offsets ⍺)rot¨⊂⍵}
   rule ← {(⍵∧(∨/0 2=2 3⍸⍺))∨((3=⍺)∧~⍵)}
   tick ← {(⊃+/,3 rots ⍵)rule¨⍵}
      glider
0 0 0 0 0
0 0 1 0 0
0 0 0 1 0
0 1 1 1 0
0 0 0 0 0
      tick glider
0 0 0 0 0
0 0 0 0 0
0 1 0 1 0
0 0 1 1 0
0 0 1 0 0
      tick tick glider
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0
0 1 1 1 0
0 0 1 1 0
(based off of the process of what I can remember from that video that went around a while back)
 
 
2 hours later…
6:42 AM
What's your opinion on function inverses. Are they a useful feature, or sth that can be omitted?
 
 
3 hours later…
9:37 AM
@ktye They're useful, sometimes. If you're implementing them, I'd suggest adding the ⍢ and ⍫ builtins though
 
 
1 hour later…
10:59 AM
@J.Sallé That is an excellent starting point for golfing.
@Aearnus Not bad at all. You may be interested in the dfns notes on GoL. Also, recently, Dyalog APL gained the Stencil operator such that f⌺3 3 applies f to each 3-by-3 neighbourhood. It makes GoL trivial.
@ktye They can be tricky to implement, and you must decide what exactly defines an inverse. Does Y≡(f⍣¯1)f Y have to be true or is it enough that (f Y)≡f(f⍣¯1)f Y? If (f Y)≡(g Y) for all Y, and both f and g are invertible. Must ((f⍣¯1)Y)≡((g⍣¯1)Y) for all Y?
@ktye Also, if (Z≢Y)∧(f Z)≡(f Y) should (f⍣¯1) f Y and (f⍣¯1) f Zgive Y or Z or error?
 
 
2 hours later…
1:33 PM
@Adám I define the inverse of a function f to be "return any X for which ⍵ ≡ f X", and the properties of inverses as whatever you can extrapolate from that, i.e. none of your s must be true by my logic. I don't think defining specific outputs to inverses is a worthwhile thing to do
 
 
1 hour later…
2:33 PM
@dzaima Dyalog does indeed do that, so 'abc'(,⍣¯1)'abcdef' works, but 'abc'(,⍣¯1)'xyzdef' does not. J takes the approach that the inverse of prepending three characters is 3↓, so the latter does work and returns 'def'.
 
3:05 PM
@Adám any suggestions on how to go about golfing that? Pretty sure most of those parens are unnecessary
 
@J.Sallé Training.
 
Yeah I'm trying that atm, not having much success though
 
@J.Sallé you have 3≥ backwards
 
@J.Sallé Start off by moving ∧/ in between the pieces, then train each one separately.
 
@dzaima what?
 
3:16 PM
@J.Sallé your code currently checks whether there are 0-3 digits, not 3+
 
@dzaima oh I must have read it wrong
thanks
Okay I think this {^/(⍵≢⌽⍵)10 3≤≢⍵,1⊥⎕D∊⍵} will be easier to train
 
@J.Sallé Are you running a test suite?
 
not yet
I'll work out the bugs in a couple, have some work to do
 
Just arrived in the Dyalog office: some light bedtime reading for the implementors.
 
@J.Sallé You should. That would save you from golfing dead-ends. E.g. your current version will certainly give you a length error with 3 elements on the left of and only 2 on the right.
 
 
2 hours later…
5:43 PM
⎕← ¯1+26⊥⍉{(27≠⍵){(+/⍺)⌽⍺×⍵}⍵}1+⎕A⍳↑'A' 'BQ' 'BAZ'
 
@PaulMansour
2107 2523 79
 
⎕←⎕IO
 
@PaulMansour
1
 
⎕← 26⊥⍉{(27≠⍵){(+/⍺)⌽⍺×⍵}⍵}⎕A⍳↑'A' 'AB' 'BAZ'
 
@PaulMansour
1 28 1404
 
5:47 PM
Golf gurus: does it make sense to turn this mess into a train?
⎕← 26⊥⍉{(27≠⍵){(+/⍺)⌽⍺×⍵}⍵}⎕A⍳↑'A1' 'AB199' 'BAZ17'
 
@PaulMansour
1 28 1404
 
Determining column number from an excel cell address, if not obvious.
A wee bit shorter:
⎕←26⊥⍉{⍵{(+/⍵)⌽⍵×⍺}⍵≠27}⎕A⍳↑'A1' 'AB199' 'BAZ17'
 
@PaulMansour
1 28 1404
 
6:12 PM
I think inline assignment is shorter:
⎕←26⊥⍉{(+/a)⌽⍵×a←⍵≠27}⎕A⍳↑'A1' 'AB199' 'BAZ17'
 
@H.PWiz
1 28 1404
 
The shortest function I have that operates on a single address is 26⊥⎕a⍳∩∘⎕a. If a short answer is all you care about
 
6:45 PM
@H.PWiz I was doing this with an each, but is slow as things get big:
⎕←{26⊥⎕A⍳⍵~⎕D} 'AA101'
 
@PaulMansour
27
 
@H.PWiz I can't get that to work. Am I missing something?
 
@PaulMansour parenthesis around the train?
 
^ Yeah, it's almost the same as what you posted
 
⎕IO←1?
 
6:48 PM
@dzaima Indeed, parens. Thanks. I'm not fluent with trains - yet.
 
@PaulMansour simple test for trains: look at the thing before a )/]/line end. if it's a function, it's a train, if an array - a regular expression.
 
@dzaima Hmmm... isn't that an array before the right paren here: (26⊥⎕a⍳∩∘⎕a) ?
I guess its composed...
so its part of the function
 
Exactly.
 
C←1000000⍴'A1' 'XX101' 'ABC1000'
cmpx '26⊥⍉{⍵{(+/⍵)⌽⍵×⍺}⍵≠27}⎕A⍳↑C' '{26⊥⎕A⍳⍵~⎕D}¨C' '(26⊥⎕a⍳∩∘⎕a)¨C'
26⊥⍉{⍵{(+/⍵)⌽⍵×⍺}⍵≠27}⎕A⍳↑C → 4.3E¯2 | 0% ⎕⎕
{26⊥⎕A⍳⍵~⎕D}¨C → 8.2E¯1 | +1808% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
(26⊥⎕a⍳∩∘⎕a)¨C → 9.9E¯1 | +2197% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Uhg, that's a mess. Dfn beats train but both are no contest vs simply matrix and no each,
 
7:07 PM
How about this for a golf:
⎕←26⊥(⊢⊖⍨1⊥×)⍉⎕A(⍳×∊⍨)↑'A1' 'AB199' 'BAZ17'
 
@H.PWiz
1 28 1404
 
@PaulMansour ¨ will always be very slow, so if you want speed, don't use it.
I feel like Dyalog isn't even trying to optimize ¨ honestly lol
 
I suspect each has to happen in a certain order in case the function has side effects, and dyalog doesn't know things like that about (non-primitive) functions
So, it just has to loop
 
@H.PWiz 26⊥(⊢⊖⍨1⊥×)⍉⎕A(⍳×∊⍨)↑C → 5.5E¯2 | +44% ⎕⎕
 
@H.PWiz yeah, AFAIK Dyalog treats dfns as black-boxes besides idioms
 
7:12 PM
For golf I assume the anyone would use an each.
 
Under normal circumstances, yes
 
@PaulMansour trains will usually be a bit slower than dfns (though that might change in 18.0)
 
Plus 1⊥ might take longer than +⌿. And I think can be slower than
 
@dzaima Indeed. But only really relevant where there is an array solution. If you code general systems in dfns, you end up using it often for looping.
 
@PaulMansour part of being good at APL is being able to write non-trivial things without ¨. APL really truly shines in ¨-free code
 
7:28 PM
@dzaima No doubt. I'm generally not very good at APL - still learning. I have a function that reads in the data of a single Excel worksheet. I then call it with an each when I want to read in all the sheets of a workbook. I'm not advanced enough to do that without an each.
 
8:04 PM
@Adám I finally solved the quadna issue I was having
@Adám trying to deal with global state and functions that are #defined can't be exported in dlls, also can't import the .h so the definitions I need aren't there... super, but hey I got it working now, and it's just wrapping the bloody things in a function which CAN be exported
a simple: export myFn(args){ return theirFn(args); }
and the same with global state, getters and setters work just fine
 
@nathanrogers nitpicking, that wasn't an APL/⎕NA issue, it was a C usage issue. it doesn't seem like whatever library you were using was supposed to be ever used by non-C code
 
I take it from a quadna issue. If I could include the header, and have all the definitions and declarations in APL, that'd be much better
 
@nathanrogers but C isn't an interpreted language!!
 
It wouldn't have to be
and no, the library I'm using doesn't seem to be very not C friendly, which is a massive shortcoming in the design of the library
 
#defines are by definition inlined in code, so it doesn't make sense for you to expect to be able to call one without having pre-compiled code that inlines it
@nathanrogers so then it's just a bad library..
 
8:12 PM
I'm not expecting that
I'm saying that why shouldn't quadna have some kind of import utility, or a code generation utility to compensate for that kind of thing, or does it and I just don't know yet?
it doesn't seem too far fetched that you could call an import utility in APL which would perform the required mapping of APL function names to dll exported methods via a header file, generating C code for wrapper functions to be included by said C code and recompiled
that seems doable based on just text scripting. but the issue was finding the work around in the first place
now that I have, I might try to make a utility like this myself
so I don't have to hand jam the other 20k lines
 
what about #define times10(a) a##0 - that's just not a thing you can import in APL, and it's not in any way at all distinguishable from a thing that can without writing a completely new limited C preprocessor parser
and #define swap(a,b) {auto t=a; a=b; b=t;}? There a special preprocessor wouldn't even help, you'd need to re-implement C
 
no, I can't import it into APL, but I could use #define, split the line on whitespace, take the second field and generate c code like void myTimes10(args) { times10(args);}
and the associated ⎕NA import statement
instead of doing all of that by hand, yes I'd still probably need to go through and type all the arguments, but that's still a lot less work
 
@nathanrogers that'd compile to void myTimes10(args) { args0;} - args0 isn't a variable that exists (and is completely not at all what the #define was supposed to do).
 
we're talking 20k lines of #define
what are you talking about? times10(a) is what you said
 
@nathanrogers but yeah, that's a thing you could automate if you wanted to do so, but definitely not a thing that's generalizable by an APL interpreter
@nathanrogers my #define times10(a) a##0 is supposed to be used as times10(123), which compiles to the constant 1230, effectively multiplying the argument constant number by 10, but that's not what your wrapper does
 
8:23 PM
oh, well I'm not talking about irregular use of precompiler macros
obviously the more complex that usage is, the more difficult it will be to generalize
 
@nathanrogers IMO more irregular use of precompiler macros is places where functions would be better off being used.
 
i didn't write the libraries
 
@nathanrogers but you chose to use them. I know there might not be other options, but I don't think it's correct to want APL to have the built-in ability to transpile & write C code because bad libraries exist either.
 
I have chosen to use them but simply because I wouldn't know where to begin to make my own, as the header alone is 20k lines, and most of it is convoluted
and it isn't because bad libraries exist, but that most people aren't exporting functions in dlls in C because they have .h files
My goal isn't to reinvent the library using APL, but to use APL to write an application which uses the library
reinventing the library from scratch would take a lot of domain knowledge that I don't have
 
@nathanrogers APL isn't the only language that isn't transpiled to C, you know.
 
8:31 PM
sofar as my C experience goes, the documentation of every library I've ever used has you importing their header and off you go
I'm not saying APL should be transpilable
but that ⎕NA is a foreign function interface
it should
i dunno
interface with foreign functions?
effectively?
 
@nathanrogers #define is a C-specific language feature. It's nowhere near being a function, let alone a universal concept.
 
I'm not saying that it is
I'm not suggesting that it should be
 
is there even a language out there that would allow importing a #define?
 
and honestly I don't know what problem you would have with having a utility that makes using a language feature easer???
Your questions are really baffling me at this point.
I said in my first message that you can't export something that is #defined
 
@nathanrogers I don't, but I do with calling it an "issue" when it's more a very big feature-request.
what if I want to be able to directly call a Java function from APL? should that also be built in Dyalog APL?
 
8:34 PM
I mean, if people need it to do that
Utilities that would reduce 90% of the workload when using a language feature missing from the language, sounds like an isue
also, the issue wasn't that I couldn't import functions
the issue was that I couldn't figure out how to include the functionality that I needed
that was the issue that I was referring to
I was using quadna, and had issues
 
@nathanrogers actually, I would really like to be able to make a direct interface from Processing to Dyalog. My current workaround of making a whole another APL quite hard to maintain :p
 
so as far as I am conserned, since I'm not writing a C application, but rather an APL application, it makes sense that I would say I had a bloody issue using quadna
 
@nathanrogers ah, ok. that makes more sense
 
you did, but I hadn't figured out how yet
and now I have.
It didn't work the first several times
namely because the first function that I'm trying this with it wasn't obvious the ⎕NA types to use, whether P, U, <U, or U[]
and also, 20k lines of code, and also a lot of static global variables that I needed to bring into APL
so now I'm probably going to work on a way to script the APL code generation so I don't have to keep doing that
and the C code for that matter
 

« first day (750 days earlier)      last day (1912 days later) »