« first day (89 days earlier)      last day (2566 days later) » 

12:15 PM
@KritixiLithos Can you solve this in 5 chars?
 
 
3 hours later…
3:19 PM
@Adám I have no idea on how to create an interactive program in Dyalog
 
3:37 PM
@KritixiLithos For simple terminal-style interaction, we've got and which are kind of special variables. If you set a value to it means output to STDOUT (with trailing newline), while setting means STDERR (without trailing newline).
If you query the value of it means get evaluated input from STDIN (i.e. whatever the user inputs will be executed as if typed into the session, and the result is the "value" of . Getting the value of means just getting a line of text from STDIN.
One useful catch: If you ⍞← and then immediately get the value of , then the outputted value will acts as a prompt and the user can edit on that same line after the prompt. So, e.g. ⍞←'C:\>' ⋄ input←4↓⍞ will look to the user like he is typing on a DOS prompt.
 
When I run ⍞←'C:\>' followed by input←4↓⍞ I don't get the C:\> in the input prompt
 
@KritixiLithos Did you run it immediately after? If you way for APL's six-space prompt, it is too late.
 
Oh, I see now
It works now that I copy the whole thing
 
You can use and to save you bytes in codegolf. Challenge: return ten minus the absolute value of the sum of a given list of numbers. dfn: {10-|+/⍵} (9 chars); train: 10-(|+/) (8 chars); tradfn: 10-|+/⎕ (7 chars).
 
dfn is a function?
 
3:49 PM
@KritixiLithos Yes, a dfn is a function written inside curly braces.
 
Then is tradfn a full program?
 
@KritixiLithos Yes.
 
How would you make {1↓⍵×⍳⍴⍵} into a train? Relevant CMC: chat.stackexchange.com/transcript/message/36915676#36915676
 
4:13 PM
@KritixiLithos 1↓⊢×⍳∘⍴ although you probably want instead of .
 
Ah, I forgot about
 
4:48 PM
@KritixiLithos and are absolutely essential in trains.
@KritixiLithos Btw, one internship for someone from PPCG has now been arranged for this summer, so the idea of internships for code golfers is definitely real. Keep up the good work!
 
@KritixiLithos Any progress on the 5-char editor?
 
Not really, I'm experimenting with to see how it works
 
Good. More important than a pesky code golf. Still, you could win this one.
 
5:15 PM
I have a 7-byte dfn
 
6:13 PM
@KritixiLithos What is it?
 
It really isn't much different from what you showed me, but here it is: {⍞←⍵⋄⍞}
 
@KritixiLithos Excellent. Now change that into a tradfn, and you're done.
 
@Adám Is it just this: ⍞←⍞⋄⍞?
 
@KritixiLithos Yes, or ⍞⊣⍞←⍞ (same thing, really, I just like it better because it flows neatly from right to left). Go head and post.
 
What does the do in this case?
 
6:29 PM
@KritixiLithos In an expression, and are pretty much just mirrors of each other. Since execution is from the right, whatever is on the right of is discarded in favor of what's on the left. This way, multiple statements can be strung together from right to left: D⊣C⊣B⊣A.
 
But they will all be executed?
 
@KritixiLithos Yes. They form one large expression.
separates multiple expressions, just like a linebreak.
This is really useful with dfn guards :. dfns continue execution line-by-line, but if a guard is triggered (what's on the left of the : evaluates to 1), then the expression on the right side of the : is the final result. But how about if you want to execute multiple expressions? Chain them from right to left with .
E.g. If given more than ten numbers return just their sum and average. If not, return all the numbers and their squares.
 result←tradfn nums;count;sum;avg;squares
 count←≢nums
 :If count>10
     sum←+/nums
     avg←sum÷count
     result←sum,avg
 :Else
     squares←nums*2
     result←nums squares
 :EndIf
 dfn←{
     count←≢⍵
     count>10 : sum,avg ⊣ avg←sum÷count ⊣ sum←+/nums
     squares←⍵*2
     ⍵ squares
 }
 
@Adám btw thanks for the help with my answer :)
 
Of course, the dfn could be golfed:
dfn←{10<c←≢⍵:s,c÷⍨s←+/⍵
⍵(⍵*2)}
@KritixiLithos You're very welcome.
 
7:01 PM
@Adám Are you supposed to have a in there somewhere?
 
@KritixiLithos If you want to type a tradfn into the APL session or a namespace, you need to begin and end with a , but if you use ⎕FX to fix a character array, you don't need them.
⎕FX'a' '⍞←⍞⋄⍞'
⎕FX 2 5⍴'a ⍞←⍞⋄⍞'
 

« first day (89 days earlier)      last day (2566 days later) »