« first day (291 days earlier)      last day (2364 days later) » 

12:18 AM
@Adám do you have any advice regarding this? I know of some 1 bytes shaveoffs, but I prefer to cut them all together. There is a slightly different version in the revisions history (almost same length)
 
@ngn ^ :-)
 
12:34 AM
btw challenges start being real pain for APL. except for the casual 5-10 byters, I begin to feel like I'm writing production code
 
@Uriel You're really good. That's why I'm turning you over to the real APL golfer for proper advice.
@Uriel Would you want to write production code?
 
 
2 hours later…
2:57 AM
@Adám Is there anything I'm missing with this Fibonacci function: {0 0⌷(+.×⍣⍵⍨2 2⍴0 1 1 1)}?
Computes [[0,1],[1,1]]^n and indexes is
 
3:08 AM
Oh, unneeded parenthesis. Also IO is now 1, I have {1 1⌷+.×⍣⍵⍨2 2⍴0 1 1 1} for 23 bytes.
 
 
4 hours later…
7:05 AM
@Adám maybe, one day. My only refrain from using APL for real applications is that it's streams/files related functions are not really "native" to the language, and looks a bit like patches. When it comes to calculations, I sometimes prefer it over python, because I can write stuff easier and faster (and in some cases get a result faster than py)
 
 
2 hours later…
9:03 AM
@Uriel You're still using 14.0, right? Try the 15.0 native file functions!
 
9:14 AM
@Adám I meant native in the context that they don't seem natural to the language, but rather an extension using the quad operator
 
@Uriel I know, but they really are called Native, hence the N prefix to their names. This is because APL predates files as we know them, so in APL lingo, File refers to APL (component) files, a system APL had to store items (both arrays and functions).
@Uriel Quad is not an operator, but rather a character which is reserved for being the first in system names which avoids name clashes with user defined names. In general, the single-char glyphs of APL are for core language only, i.e. computational and structural things. Only exceptions are & and .
 
9:32 AM
@Adám makes sense, but couldn't you use some symbol like ⍞ for file operations?
 
@Uriel APLX did that for component files, but frankly, I find their symbols not very mnemonic, and the syntax more awkward than elegant. Have you looked at ⎕MAP?
 
9:59 AM
@Adám I guess I would give a deeper look on files operations once I get on a PC; frankly, I haven't done much APL stuff that runs repeatedly (like GUI apps or infinte input stream related operations)
 
10:42 AM
@Uriel For streams, you may want to have a look at Arbitrary Input and Arbitrary Output.
 
ngn
10:53 AM
@Uriel I'll need some time to comprehend your solution fully. In the meantime, here's a quick improvement: replace ∘., with ,¨
@Uriel another trick: if you have a dfn that uses ⊃⍵ and ⊃⌽⍵ from pair ⍵ you can replace it with its reduction and use ⍺ and ⍵ instead of ⊃⍵ and ⊃⌽⍵
@Uriel I mean replace: {k∊(⊃⍵){⍵>k:⍺⋄⍺,⍵∇⍺+⍵}⊃⌽⍵}
with: {k∊⍺{⍵>k:⍺⋄⍺,⍵∇⍺+⍵}⍵}/
 
11:11 AM
@ngn thanks! these ⊃⍵ and ⊃⌽⍵ really hurts my eyes
I think I can cut down some bytes of this as well
 
@ngn @Uriel Isn't that the same as (k∊{⍵>k:⍺⋄⍺,⍵∇⍺+⍵})/?
 
@Adám @ngn just golfed another 6 bytes and saved tons of memory: codegolf.stackexchange.com/a/147839/65326
About 1 second for n=1000 with previous ~7 sec
 
ngn
@Adám yep, it could be a train
@Uriel why do you have to grade by half the sums? you can grade by the whole sums
 
@Uriel Save another two bytes by converting to tradfn: replace rightmost with and remove the outer braces.
 
11:28 AM
@ngn o right
@Adám how can I run the test suit the same?
 
@Uriel Try it online! Niladic resultless "functions" are terrible style, but hey, it's all worth it to chop another couple of bytes!
 
ngn
@Uriel I tried rewriting this bit: {k∊⍺{⍵>k:⍺⋄⍺,⍵∇⍺+⍵}⍵}
or with Adam's improvement: (k∊{⍵>k:⍺⋄⍺,⍵∇⍺+⍵})
as: {⍵≥k:⍵=k⋄⍵∇⍺+⍵}
It seems to work.
 
@Uriel You're TIO link is out of date.
 
@ngn I already changed that one, only with alpha instead of Omega. Great minds...
@Adám o thanks. too many updates.. xD
 
ngn
@Uriel it's a shame the calculation of "o" takes so many chars but I can't improve it...
 
11:44 AM
@ngn well, it does look pretty optimal
then again, it used to before :P
 
ngn
11:58 AM
@Uriel if only the pairs in "o" could be generated in ascending order of their sums, you would be able to avoid the grading and square-bracket indexing
 
@ngn you think that's possible without grading?
 
ngn
@Uriel if the o-s are in ascending order, you could simply take the first (⊃) after filtering (/⍨)
 
@ngn I meant whether it's possible to create such o without many bytes
 
ngn
@Uriel well, I don't know for sure, I'm just throwing an idea
this: o←⊃,/{i,¨⌽1+i←⍳⍵}¨⍳1+k
is one way to do it, possibly golfable further, but I can't get the whole solution to work
@Uriel actually, ignore the above, it's wrong - generates pairs where first≥second
 
12:15 PM
@ngn I have a theorized solution that might work, I need to go right now, but I'll test it and be back in a few hours. Let me know if you find something interesting. Thanks!
 
 
2 hours later…
ngn
2:06 PM
I think it worked: ⊃o/⍨{⍺≥k:⍺=k⋄⍵∇⍺+⍵}/¨o←⊃,/{i,¨⍵-i←⍳⌈⍵÷2}¨⍳1+k←⎕
only 1 char shorter :(
 
Oh nice
Just came back to send here tio.run/…
@ngn ^
 
ngn
2:31 PM
@Uriel further -2 chars: ⊃o/⍨{⍺≥k:⍺=k⋄⍵∇⍺+⍵}/¨o←a/⍨</¨a←,⍉|-\¨⍳2⍴1+k←⎕
 
ngn
2:45 PM
@Uriel I'll try to golf a bit more before I give up - there's a trick for computing the Fibs - you do +\⌽⍵ multiple times, e.g. using the power operator ⍣ but it's not guaranteed it leads to fewer characters here
he-he, another 2 chars fell surprisingly quickly :)
⊃o/⍨k∊¨+\∘⌽⍣{k≤⊃⍺}¨o←a/⍨</¨a←,⍉|-\¨⍳2⍴1+k←⎕
 
Weirdest operator ever: ∘.
 
ngn
@EriktheOutgolfer historical artifact
 
1) two chars, instead of the usual one char 2) gets its argument to the right instead of the left
mostly 2) is what makes it weird, 1) just makes it the weirdest
 
ngn
@EriktheOutgolfer it used to be a dyadic operator (.) with ∘ as the left operand, ∘ at the time represented a non-existent value
 
and btw is there any way to assign anything to + for example?
because )ERASE + doesn't seem to succeed
 
ngn
2:54 PM
@EriktheOutgolfer very good question :) @Adám you must show this to Morten :)
@EriktheOutgolfer it's an old argument we've had since forever
 
@EriktheOutgolfer No, you cannot overload or replace built-ins in Dyalog APL. However, they are pre-overloaded for .NET objects.
 
ngn
@EriktheOutgolfer Dyalog does not allow re-assigning the primitives
 
@EriktheOutgolfer Yes: Use ngn/apl.
 
@Adám how about overloading numerals, like forth?
 
ngn
@Uriel example?
 
3:00 PM
@ngn ok this is pure madness. I need to work my way through it
@ngn 3←'a'
 
ngn
@Uriel in my mind there's a significant difference between + and 3
@Uriel "+" is the name (or rather symbol, which is like an abbreviated name) for the function that does addition
@Uriel "3" on the other hand is a numeric literal, it's a concrete value
@Uriel I advocate being able to reassign symbols, especially after watching Guy Steele's "Growing a Language", but I don't think we need to mess up with literals.
 
@ngn In I, even 3 is a function, which returns the number three (i.e. itself).
 
Well, frankly it just means that numbers can be used as variable names
 
3:24 PM
@ngn ok, I just updated the post. let's hope that's the last time...
 
ngn
@Uriel I don't plan to torture it any further.
 
@ngn hmm. I just finished going through the logic, seems it produces o where higher maximum pairs are created first for each mean. any idea how to change it?
 
ngn
@Uriel is that a problem?
 
@ngn there's a theorem running around the post that there aren't multiple solutions of same mean, but it hasn't been cleared up yet
I guess I'll start get cracking on that proof
 
ngn
3:39 PM
@Uriel hm, the problem statement explicitly mentions this case, and the "theorem" has no proof yet. This can be fixed at the cost of an extra ⌽ before the ⍉
 
@ngn yeah, just figured it
btw the matrix idea is really freaking nuts
I tried something similar using the upright part of a outer prod but it ended up being longer than the full solution itself
 
 
1 hour later…
4:49 PM
@Adám so APL does have reserved words ;)
@Adám that's Dyalog APL's child :) and yes I have used ngn/apl in the past
also, have I mentioned that I'm addicted to APL?
@Adám and in Jelly, everything is either a link (i.e. function) or a quick (i.e. operator)
for example 3,4,5 is a niladic link that returns the list (i.e. array) [3, 4, 5]
[3,4,5] is the same link, just with explicit brackets
in APL I can't say that's true
and btw @ngn how do I get a list of all <char><char>TAB and BACKTICK<key> combinations in the "official" ngn/apl interpreter? (ngn.github.io/apl/web)
for example `~ makes ¤, which isn't documented anywhere...
@Adám how?
 
5:33 PM
@ngn what are ≈⍫⍁∞↗?
 
ngn seems to be off, so I'll answer for some
@Uriel ↗ will throw an error, e.g. ↗'Error: Operation not supported.'
@Uriel ∞ is an infinity literal ()
@Uriel ≈ simply doesn't exist ()
(otherwise it would've outputted #procedure)
and it's not an in-function thing too: {≈}
for ⍁ and ⍫, well, I have to say I'm not really sure yet, just that ⍁ is an operator and ⍫ is an in-function thing like ∇
 
5:52 PM
Thanks
 
oh, and I think what ⍫ does is essentially exit the program returning its argument, something to be used only in functions
interestingly, both ¯ and ∞ represent infinity, but the latter can be used to golf an array containing infinities
 
6:12 PM
@Adám is this implementation of the . operator correct? {⍺⍺ ⌿ ⍺ ⍵⍵ ⍵}
in ngn/apl it's 2 bytes shorter: {⍶⌿⍺⍹⍵}
 
@EriktheOutgolfer Only for scalar/vector arguments.
@EriktheOutgolfer You can remove all spaces from the Dyalog one, and ngn/apl is UTF-8. ( and are not in the character set.)
 
@Adám what do you mean?
@Adám I saw it scored in bytes somewhere, is it a mistake?
 
6:27 PM
⎕←(+.×⍨2 2⍴⍳4) (+{⍺⍺⌿⍺ ⍵⍵ ⍵}×⍨2 2⍴⍳4)
 
@Adám
┌─────┬─────┐
│ 7 10│10 20│
│15 22│     │
└─────┴─────┘
 
@EriktheOutgolfer ^
@EriktheOutgolfer Yes:
43
A: When can APL characters be counted as 1 byte each?

Adám GNU APL and ngn/apl use UTF-8, so use a byte counting tool. NARS2000 only uses UCS-2, so 2 bytes per character. IBM's APL2 is the only modern APL that natively supports APL EBCDIC, so 1 byte per character. Dyalog APL uses any Unicode format, or the classic Dyalog character set (Table 1 below).* ...

 
@Adám hmm
by 2015 we already had byte-scoring rules right?
 
@EriktheOutgolfer I'm not certain when we switched. Maybe search through Meta?
 
that's what I'm doing rn
@Adám yes, looks like we did
this answer looks like it's been scored on chars
even when the question was asked we already counted with bytes
> # of characters
oh d' oh
in dyalog apl it would've still been 10 bytes, since we don't count ⎕IO
 
7:02 PM
@Adám oh so it's much more complicated
⎕←(⎕←2 2⍴⍳4){⍺⍵}.{⍺⍵}(⎕←2 2⍴4+⍳4)
 
@EriktheOutgolfer
5 6
7 8
1 2
3 4
┌─────────┬─────────┐
│┌───┬───┐│┌───┬───┐│
││1 5│2 7│││1 6│2 8││
│└───┴───┘│└───┴───┘│
├─────────┼─────────┤
│┌───┬───┐│┌───┬───┐│
││3 5│4 7│││3 6│4 8││
│└───┴───┘│└───┴───┘│
└─────────┴─────────┘
 
⎕←(⎕←2 2⍴⍳4){⍺⍵}{⍺⍺⌿⍺⍵⍵⍵}{⍺⍵}(⎕←2 2⍴4+⍳4)
 
@EriktheOutgolfer
5 6
7 8
1 2
3 4
┌─────────┐
│┌───┬───┐│
││1 2│5 6││
││3 4│7 8││
│└───┴───┘│
└─────────┘
 
@ngn @EriktheOutgolfer Now that we have we can retcon ∘.f as syntactic sugar for f⍤0 15 because 15 = ∞ for sufficiently small values of ∞.
 
what ∞
 
7:15 PM
@EriktheOutgolfer Theoretically speaking, ∘.f is the same as f⍤0 ∞ but since Dyalog (for technical reasons) restricts rank to ≤15, 15 is sufficient.
 
ngn
≈ is intended to be approximate equality like ≈←{eps>|⍺-⍵} but I never actually needed it; in ngn/apl some "primitives" are implemented in terms of others.
⍫ is a reified return. What I really wanted to implement was continuations but I settled for this.
⍁ binds a function (usually a user-defined one) with its identity element, used for reductions on empty vectors.
∞ is obviously infinity. Dyalog don't like it but I don't have a problem with it.
↗ is "raise" a.k.a. "throw", a.k.a. ⎕signal
I don't recommend ngn/apl for anything more serious than sharing a one-liner with a friend. It's a by-product from me learning how to implement programming languages. I made some mistakes.
 
@ngn nah, TryAPL is set to accomplish that one too :p
but currently it's a bit behind the current version
 
@ngn so did Oracle. A big one :P
 
ngn
@Adám Have you come across the definition of ∘.f in The Dictionary?
 
@Uriel Big as in byte-count? ;-)
 
7:21 PM
huh
 
ngn
@Uriel are you referring to Java?
 
@ngn No, but it can be inferred from there. Dictionary says that ∘.f is 0 .f and n.f is f⍤n ∞, so ∘.f is f.0 ∞. However, it is pretty obvious. ∘.f means that every element of the left argument gets paired (all combos style) with every element of the right. In other words, every element of the left gets paired with the entire array on the right. Hence f⍤0 ∞.
 
ngn
@Adám sounds right :)
 
7:38 PM
@ngn yup
 
7:52 PM
what is that dictionary
 
@ngn btw the new solution is not much slower than the previous (second version of second one), but fills the ws pretty quickly because of the double range
 
ngn
@Uriel well, they only judge us by the number of bytes :)
@EriktheOutgolfer the link Adam sent - that is Ken Iverson's later attempt to write a spec for APL, after realising some of his mistakes
@EriktheOutgolfer later that became the basis for J
 
@EriktheOutgolfer You can kind of follow the chronological development of APL/J here.
 
ngn
8:12 PM
@Adám APL->k evolution, obviously in much more concise form :) at the bottom of: kparc.com/lisp.txt
 
9:10 PM
does anybody know how behaves?
 
@EriktheOutgolfer it branches to the specified label
 
for example {→0} is a syntax error...wonder why
or does it work only in tradfns
 
Language reference > primitive functions > functions a-z > branch
 
10:16 PM
@EriktheOutgolfer Documentation It is only really useful in tradfns, however "naked" branch (without line number/label "argument") does work in dfns where it cuts the stack back (just like it does in tradfns).
 
@Adám can you give an example?
 
@Uriel Example of of using in a tradfn?
@Uriel Using with a calculated line number:
x←Fact x
→2×x≠1
x×←Fact x-1
@Uriel Using with a line label:
r←Fact x;i
r←1
i←0
LOOP:i+←1
r×←i
→LOOP/⍨i<x
@Uriel Contrived example of using in dfn to force user to enter a non-zero input: {0≠⎕:→⋄∇⍬}⍬
 

« first day (291 days earlier)      last day (2364 days later) »