« first day (1182 days earlier)      last day (1478 days later) » 

12:20 AM
0
A: Sandbox for Proposed Challenges

xnorSquare snowflake Produce this square snowflake. XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XX X X X X X X X X X X X X X X XX X XXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXX X XX X X X X X X X X X X X X ...

Looks like a cool task for APL.
 
1:07 AM
First stab as a Game of Life variant: ' X'[⎕IO+(⊢∨{1=≢⍸⍵}⌺3 3)⍣≡⊢63 63↑¯32 ¯32↑1]
 
1:20 AM
{1=+/,⍵} is noticeably faster than {1=≢⍸⍵}, which I'm guessing is a matter of ≢⍸ being unoptimized
 
 
6 hours later…
6:55 AM
@AntonDyudin No, it is {A=+/,⍵}⌺3 3 that is optimised for any constant A
@AntonDyudin Unfortunately, 819⌶ isn't scalar, though I think it is obvious that it should be. It's 18.0 replacement, ⎕C isn't scalar either, but isn't limited to characters either.
 
@Adám If it isn't limited to characters, what does it do on numbers?
 
@Bubbler Nothing, just like monadic + ignores non-numbers, ⎕C ignores non-characters. Should still be scalar though.
It is made that way so you can case-fold an entire array of mixed data at once.
 
RGS
@Bubbler it's not that the figure is incorrect. It is just that the trapezoid rule is being used over n intervals and the Simpson's rule is being used over n/2, where n is even. And thus the comparison between T and S is not as fair and not as obvious
 
7:12 AM
@RGS I'd consider that comparison fair because they're using the same number of data points.
 
RGS
7:47 AM
@Bubbler but the point is that Simpson is more accurate because it is more complex, and usually Simpson's rule in a subinterval is defined at the expense of an auxiliar point which is the midpoint of the interval.
The thing here is the spirit of the methods, as T in an interval is the linear interpolation of the function in that interval and S in an interval is supposed to be quadratic interpolation in that interval; yes, at the expense of an auxiliar point, but that is why S becomes order 2 and T is only order 1. You are supposed to compare the methods in the length of the intervals used for the interpolations.
Of course that you can (rightfully) state that for the same number of intervals, S uses computes the function in more places. What I'm arguing is that from the numerical integration point of view, this comparison makes more sense
 
8:09 AM
OK, I think I get it.
 
 
4 hours later…
RGS
11:49 AM
@Bubbler but then again, maybe I got a bit carried away; it wasn't really an important thing. I just wanted to voice my confusion when I checked the figure
 
 
2 hours later…
1:54 PM
Is it considered good taste to 'inline' variable assignments? E.g:
m[(≢?≢)m←¯1↓1↓⍵]
 
So how does it work once the event starts?
 
@xpqz It is fine, and traditional, but I prefer (⊢⌷⍨∘⊂≢?≢)¯1↓1↓⍵
@AviF.S. We just keep chatting.
 
How easy! Super looking forward to it!
Random question: Is it in the works for the Dyalog GUI to be able to import/export color themes, so they can be shared?
Currently, you can customize your own to no end, but it seems everyone is on their own...
 
@AviF.S. Which IDE are you using, Windows IDE or RIDE?
 
Sorry, I did mean to say RIDE, but I wasn't sure if that's what it was called and didn't want to embarrass myself!
It's RIDE, the OS one!
And Linux, I assume?
 
2:01 PM
RIDE is cross-platform.
 
@xpqz Not by me. Ok for code golf, but not good for production code.
 
@Adám ha :) (⊢⌷⍨∘⊂≢?≢) amazing
 
@AviF.S. you can "export" the theme from the help→about→colourSchemes, and import by manually writing in ~/.config/Ride-X/prefs.json
 
@PaulMansour I'm in two minds. I wrote it to save a line, for sure.
 
@xpqz isn't expensive at all, but it kind of bothers me to do it twice. (⊢⌷⍨∘⊂?⍨∘≢) would work too.
 
2:04 PM
Sorry, lost connection!
 
@xpqz imo it's acceptable for bracket indexing, while isn't here yet
 
@dzaima Super helpful! Thanks a bunch!!
 
(here's what i use, not-too-contrasty dark theme)
 
2:20 PM
Thanks a bunch! I'll try it right now. Been trying to create a good dark theme!
 
@xpqz I think the real issue is "is one coding at the same level of abstraction"? If I see a train (or any bunch of primitives) or a golf trick or an embedded assignment dangling off the end of an :IF statement in a trad function, not good for readability. If things are in a well-defined and well-named dfn, where attention has been paid to every detail to make things short, its generally OK (though I still avoid embedded assignment.)
 
@PaulMansour How would you feel about ⊢⊇?⍨∘≢ "argument reordered by shuffling the tally"?
 
@Adám How would I feel about it where?
 
@PaulMansour In production code.
@xpqz Could have APLcarted it
 
@Adám Its not really a question of production code as I noted above. It a question about the level of abstraction in the function.
 
2:27 PM
@dzaima Hmm... I'm having trouble finding prefs.json. And no Ride representative is in my config folder.
 
If your production code is a 200 line trad function with loops and nested :if :then :elses, then that line of code, naked, is out of place.
 
Clarifying question: I do have an app called RIDE, but I usually use the one that's just called 'Dialog 17.0' (now 17.1). Is that still RIDE in disguise?
 
@AviF.S. yeah
 
Because RIDE always forces a remote connection, which I thought was the point of RIDE, and the other doesn't...
What's the difference/
(Or maybe the other's remote connection is just set to remember the details by default, and I installed two different versions...?)
 
@AviF.S. i'm guessing the Dyalog one just still makes the "remote" connection, it just hides the fact
 
2:30 PM
RIDE can both work remotely and locally. The "Dyalog 17.0" is meant to look "local".
 
I see, that makes a lot of sense. Thanks!
 
Welcome to APL Cultivation!
Please excuse me if I'm a bit distracted, as I have a parallel meeting going on.
First thing: Today's subject.
One thing that has been suggested is how to write APL code for "do-while" type problems.
@all Any other ideas?
 
@AviF.S. just tested, the file i named definitely affects the Dyalog version of launching RIDE, can't really help other than try tracing where else could the configs be stored
 
RGS
@Adám I'm up for anything
 
@dzaima Thanks!
 
2:32 PM
Do-while is a good idea; it's a good follow-on from last time's for-each.
 
OK. Maybe I don't have as much to say, but let's give it a go. Feel free to chime in with your own ideas.
 
@Adám Am curious in general if there are any other more APL-esque constructs for while/for structures without using the ∇WHILE-type constructs. They always struck me as not in the spirit...
 
Right, as Avi is mentioning, modern APL does have :While-:EndWhile and :Repeat-:Until.
 
I've often tried abusing the ⍣ operator, but as it's not meant for it, it usually doesn't work. Sometimes it does, but even then it's obscenely obfuscated
 
Yes, the operator is an option, you just need to know how to apply it right. We can look at that.
And then there's recursion, which isn't bad in APL, as you can use the optimised tail-recursion.
 
2:36 PM
I dont mind the ⍣ if its 1/lambda, however (at least in gnu apl), the right tack still executes. For example:

⎕←'there'⊣⍣1⊢⎕←'here'
here
there
⎕←'there'⊣⍣0⊢⎕←'here'
here
here
 
(Perhaps also learning how to apply ⍣ with side-effects, eg, if you want to print particular values as you generate them)
 
/me still thinks in TradAPL, and will tend to write repeat-untils with an expression like →bool/linenumber at the bottom...
 
(So far, I usually initiate an empty list, and then append to it in ⍣ and then print it afterwards... perhaps there's a better way?)
 
@AviF.S. That's fine, if you're building a list. It could also be mutating a (semi-)global variable "until".
@cannadayr But that's a simple if/else. I'm not sure I understand what you mean. Can you explain more?
About , it is important to note that it always applies its left operand at least once.
 
2:41 PM
So let's take a very simple (pun intended example). Lets say we have an array like ⊂⊂⊂⊂2 2⍴'ok'
We want to disclose it until it is simple. (If we do ⊃⍣≡ we'll end up with 'o'.)
 
(@dzaima Holy moly! I have to admit I have no idea what any of that is! Somehow, I managed to learn Vim and still don't know Bash!)
 
An easy pitfall is also to use in the right operand (the one that answers "are we done?") instead of .
      ⊃⍣{1≥|≡⍺} ⊂⊂⊂⊂2 2⍴'ok'
ok
ok
The problem is that our input might have 0 levels of nesting; then we fail:
      ⊃⍣{1≥|≡⍺} 2 2⍴'ok'
o
This is because is being applied once before we even ask if we're done.
 
So apply ⊂ once before you start disclosing?
 
That wouldn't be a general solution. There might not be an inverse.
If instead we move the test inside the left operand…
      {1≥|≡⍵:⍵ ⋄ ⊃⍵}⍣≡ 2 2⍴'ok'
ok
ok
 
RGS
So we're looking for a fixed point of the left operand?
 
2:49 PM
Yes, because the left operand will become a no-op when we're done.
In fact, we can even use the power operator instead of the guard!
      {⊃⍣(1<|≡⍵)⊢⍵}⍣≡⊂⊂⊂⊂2 2⍴'ok'
ok
ok
      {⊃⍣(1<|≡⍵)⊢⍵}⍣≡ 2 2⍴'ok'
ok
ok
 
So is that basically {1≥|≡⍵:⍵ ⋄ ∇⊃⍵}?
without the ⍣
 
@xpqz Yours is the recursive equivalent, yes.
 
But the power version will be more efficient in Dyalog?
 
RGS
@Adám I missed the point of having a ⍣ inside the left operand; are guards frowned upon?
 
@RGS No, I'm just saying.
 
RGS
2:53 PM
Ah ok, you were just showing us
 
Yep.
Of course, you don't have to write everything inline. You could use a separate function for the main processing.
In your left operand, you can of course place your done-condition at the top or at the bottom, or anywhere else.
But let's say instead that we don't want the condition to be based on the data processed. Rather, we want to periodically read an outside value to decide whether to continue or not.
You can try this in your local APL: done←0 ⋄ {⎕←⍵⊣⎕dl 5}⍣{done}&'work'
It will run in the background, printing "work" every 5 seconds.
 
RGS
Until "done" is set to 1
 
Yes, if you (quickly) enter done←1, it'll stop.
 
⎕dl is a delay function?
 
Yes. DeLay
 
3:02 PM
/me nods
 
Of course, it didn't need to be a single value in {done}. It could be an entire function that figures out if we're done based on a bunch of stuff.
So, any remaining problems with ?
 
Wait, the solution given before of {⊃⍣(1<|≡⍵)⊢⍵}⍣≡⊂⊂⊂⊂2 2⍴'ok' was a general case fix because might not always have an inverse, you said. But in the end, it uses anyway...
I only just noticed
 
RGS
@AviF.S. We were always using ⊃, the function we really want to apply. someone suggested we started by using an extra ⊂
Not the other way around
 
@AviF.S. No, (i.e. the "work") might not have an inverse.
 
Haha, I'm sorry! I totally misunderstood :laughing emoji thingy:
 
3:10 PM
I think this is what we need about . Shall we move on to recursion?
 
RGS
sure!
 
OK, so recursion can be done simply by calling the function name. Dfns can also call themselves using .
The benefit of is that you can rename the function or leave it anonymous.
 
RGS
Makes sense
 
I should also mention ∇∇.
If you are as advanced as writing your operators, you might want the operator's code to "use" itself. You do that with ∇∇.
Inside such a dop, you can also use as a shortcut for ⍺⍺∇∇ or ⍺⍺∇∇⍵⍵ depending on operator valence.
 
RGS
So with ∇∇ you can apply the operator to other arguments and ∇ acts as an alias for ⍺⍺∇∇ (or ⍺⍺∇∇⍵⍵)?
 
3:17 PM
@RGS Exactly. ("operands" though)
 
RGS
@Adám ("operands" instead of "arguments", correct?)
 
Well, both, actually. allows you to apply to any desired arguments, but keeping the operands. ∇∇ allows you to also switch operands.
 
RGS
Understood!
 
Other than this, it is actually much the same as with : Establish the stop condition with a guard (or a control structure in a tradfn), and do the work otherwise.
I think a great example popped up…
in The Nineteenth Byte, yesterday, by Anush
CMC Write down 7 consecutive numbers so that the digit 2 is used exactly 16 times.
I answered with a recursive solution:
in The Nineteenth Byte, yesterday, by Adám
Found with {16=+/'2'=⍕⍵:⍵⋄∇1+⍵}⍳7 in APL. Try it!
While dzaima posted the -based alternative: 1∘+⍣{16=+/'2'=⍕⍺}⍳7
Notice here how the left operand (the "work") is extremely simple; just the increment function, while the actual work is in the condition function.
 
Very elegant answers
 
3:27 PM
Yes, tail calls.
The important thing is that APL detects when the final result will be used unmodified as the result of the previous iteration.
So, let's say we wanted the beginning number of the 7-long sequence: {16=+/'2'=⍕⍵:⍵⋄⊃∇1+⍵}⍳7
Now APL has to keep track of where came from so we can apply that final .
Can we detect a tail call? Yes. :-)
You can try this: {⎕←≢⎕SI ⋄ 16=+/'2'=⍕⍵:⍵ ⋄ ∇ 1+⍵}2000+⍳7 (I've made it start searching at 2000 to prevent output flooding.)
⎕SI is the State Indicator, or stack.
So, every time around the loop, we count the frames on the stack and print that.
It'll print 1 every time, because the stack "forgets" about the previous call every time.
Now try it with the then: {⎕←≢⎕SI ⋄ 16=+/'2'=⍕⍵:⍵ ⋄ ⊃ ∇ 1+⍵}2000+⍳7
 
RGS
SI increases, but moving the ⊃ to the guard return makes it output only 1s again...
And yet, I don't understand what is the difference that allowed Dyalog to do that.
 
@RGS What is your code?
 
RGS
{⎕←≢⎕SI ⋄ 16=+/'2'=⍕⍵:⊃⍵ ⋄ ∇ 1+⍵}2000+⍳7
That one only prints 1s
I moved ⊃, of course... but I can't comprehend why Dyalog manages to optimize one and not the other
 
@RGS Of course, as that is the final result that gets passed back.
 
ngn
@Adám no need for there
 
3:39 PM
@ngn True, not in Dyalog APL.
@RGS Dyalog looks ahead if the result will be used. This is also in effect for "shy" functions and assignments. Sometimes it will not even compute something if the result won't be used.
 
That means it also has to detect whether the computation has side effects.
 
@JeffZeitlin It doesn't take it that far. An APL interpreter has to anyway look a few tokens left to parse correctly.
 
ngn
@AviF.S. should be under ~/.config/Ride-4.3/ or similar. you can find out the exact path by pressing f12 and typing D.el.app.getPath('userData') in the js console
 
@ngn i don't like using of
@ngn ah, that's much more sane than straceing.. ¯\_(ツ)_/¯
 
@ngn Thanks a bunch! I'm trying it
 
3:46 PM
@all Any questions about recursion?
 
RGS
@Adám (not from me)
 
Me neither! Thanks @Adám for doing this even despite the meeting
 
No problem. Let's finish with an exercise: I assume you're all familiar with the Fibonacci sequence. Try implementing Fib n (which returns the nth Fibonacci number) using and recursion.
 
RGS
the n-th term, the first n terms, or whatever we please»
?
 
> which returns the nth Fibonacci number
But by all mean, try "first n" too.
 
RGS
3:50 PM
fib ← {0=⍵:⍺ ⋄ ⍺←1 ⋄ ⍵×⍺ ∇ ⍵-1}
 
@RGS I think you mean +, not ×
 
RGS
wait I did factorial ahaha
fib ← {0=⍵:⊃⍺ ⋄ ⍺ ← 0 1 ⋄ (¯2↑⍺,+/⍺) ∇ ⍵-1}
And checking with fib ← {⎕←≢⎕SI ⋄ 0=⍵:⊃⍺ ⋄ ⍺ ← 0 1 ⋄ (¯2↑⍺,+/⍺) ∇ ⍵-1} it uses tail recursion
 
Very nice. Well done!
 
RGS
If I wanted to recurse on a function that takes a left and a right argument, how could I do this "trick" of carrying the calculations down the recursion..?
 
@RGS You already did, no? There's a hidden "seed" argument 0 1
 
RGS
3:58 PM
but that is the initialization, because I only really call fib with 1 argument
but say I wanted to call a function f with two arguments
 
Right, but say you'd implemented a Lucas number function instead.
 
RGS
and I would need a 3rd one for the actual calculations, going down the recursions...
 
I suppose I did the first n instead, whoops! This is just to test the bot, I've never tried it before
 
RGS
@Adám just let me google that real quick
 
{10=≢⍵:⍵ ⋄ ∇ ⍵,+/¯2↑⍵}1 1
Darn
How does one prompt it?
 
3:59 PM
The bot died of COVID-19.
 
{⍵,+/¯2↑⍵}⍣{10=≢⍵}1 1
Haha, only fair!
 
ngn
@RGS make it an operator and use ⍺⍺, or put the args&accumulator in a vector
 
RGS
@Adám for the Lucas function I would only have to swap the init values of ⍺, right?
 
Is there a better way to do that, aside from the closed form, which sort of ruins the recursive point? And aside from the matrix version, which is more APL-esque but less... well, maybe I'm just being lazy
 
@RGS You'd simply not initialise inside, but let that be the left argument.
 
RGS
4:02 PM
@Adám But that is because you took the example to be the Lucas numbers, which follow the same "add the previous two" pattern of Fibonacci and you abstracted away the seed
 
@RGS Right. So in a more general case, ngn's advice stands. Alternatively, you could use a variable outside to keep information in.
I think this concludes today's lesson. Thank you for participating!
 
RGS
@Adám yup, I see. It is just that ngn's advice will have me parse the input to discern if I'm already recursing or if I should start recursing now
Thanks Adam!
 
OK, I managed to get a fib that isn't tail recursive, by translating the "classical" algorithm...
fib←{1=⍵:1⋄2=⍵:1⋄(∇⍵-1)+∇⍵-2}
 
Wait, how does the construct work that goes something like: 2 +⍣3 1
That would calculate 2+2+2+1?
 
@AviF.S. 2 +⍣3⊢1 or 2(+⍣3)1
 
4:07 PM
Not how does it work, but how do you write it, I mean
Thanks!
So adopting the matrix multiplication version of the nth fibonacci algorithm with ⍣
I suppose one could do
⊃m(+.×⍣3)m←2 2⍴1 1 1 0
 
@AviF.S. If you know the naming scheme used by APLcart, you could search for f⍣Js.
 
Well {⊃m(+.×⍣⍵)m←2 2⍴1 1 1 0}
But that's imperative instead...
 
Why imperative?
 
@Adám That's super good to know! Thanks! I use APLcart frequently; it'll come in handy
 
@Adám hm, why does it sometimes use Is and sometimes Js?
 
4:11 PM
@dzaima Is on the left of the main subject, and Js on the right.
 
I thought it was, at least... It's being told exactly what to do and does so $n$ times.
I would have thought of that as akin to a for loop, and as being imperative
Whereas the recursive version as the functional version
 
@AviF.S. Btw: {⊃+.×⍣⍵⍨2 2⍴1 1 1 0}
 
Is that not an accurate understanding of the different paradigms?
@Adám Goodness gracious. I missed my chance; you're right!
 
@Adám ah, i'd have thought to order alphabetically starting with first always, so search queries are always clear
 
@AviF.S. I disagree. Haskell has spread this notion of recursion being "the" functional way to do things, but this is just as functional. You're not telling APL exactly what to do, but how ("thrice") you want your function applied.
@dzaima That'd have been a possibility, but I wanted to align myself with the refcard which uses X/Y and f/g like that.
 
4:14 PM
@Adám ah, understandable
 
Hmm, well if Haskell is a source of misunderstandings, I have to agree, that was my intro the functional world (though I've played around with Lisps as well)
But I still would have thought it imperative...
Because you are telling it precisely what to do, namely multiply the matrix by itself $n$ times. I suppose I'm not seeing the functional aspect
 
You're also telling it exactly what to do when you recurse. Pretty much all programming is telling the computer exactly what to do. (Except in Prolog, of course.)
In computer science, imperative programming is a programming paradigm that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program consists of commands for the computer to perform. Imperative programming focuses on describing how a program operates. The term is often used in contrast to declarative programming, which focuses on what the program should accomplish without specifying how the program should achieve the result. == Imperative and procedural programming == Procedural programming is a type...
 
Ah, not only was I unclear in what I was saying, which you caught and corrected (ie logical programming/Prolog), but you're entirely right on the matter
 
> statements that change a program's state … describing how a program operates … in contrast to … what the program should accomplish
 
My snafu, I suppose there's no changing state!
Thanks for clearing that up, @Adám
 
4:20 PM
No problem at all. Always my pleasure.
 
:)
 
RGS
@Adám can I include a guard inside a dop?
 
@RGS Yes.
 
RGS
with the usual syntax, yes?
 
Yup.
 
RGS
4:22 PM
Then I messed something up :upside_down_face:
 
APL is very much geared for exploration. You could just try, you know :-) Oh, you did. :-(
 
@ngn Not sure how I'm failing at all this, but am unable to find the js console in RIDE, or in the brief moments I searched the help manual. And, of course, I had to be on a Mac so my function key bindings don't work as they should
 
@AviF.S. there should be a configurable keybind for it - "Show JavaScript console"
 
@dzaima You're entirely right! Terribly embarrassing how quickly you guys find this stuff!
 
RGS
@Adám was trying to write this:
_LinRec_ ← {
    ⍝ Dyadic operator that allows one to generate any sequence that arises from a linear recursion.
    ⍝ The left operand gives the weights of the sum and the right operand gives the initial values.
    ⍺ ← ⍺⍺
    1=⍵: ⊃⍺
    (⍵-1) ∇⍨ (-≢⍺⍺)↑⍺,⍵⍵+.×⍺
}
but had the syntax for the dop all mixed up and as a side-effect I wasn't being able to use the guard. at first I thought I couldn't use it, but as the dop kept insisting on not working, I realized maybe the problem wasn't the guard
 
ngn
4:28 PM
@AviF.S. how does one show the js console in chromium/chrome on a mac? it should be the same
 
@RGS Where did the tracer stop?
 
RGS
Also, the first time I was told about operators, I thought they were supposed to return dfns, but the dop I included above just seems to be working as a regular dfn, except I have access to 4 arguments instead of 2...
@Adám when I had the guard, at the guard!
but the problem was coming from elsewhere, except it only showed up when executing the guard. but now all is good
 
@RGS Right, they cannot return functions. Rather, they specify how their derivations should work.
 
RGS
@Adám I don't know what that means :)
 
@AviF.S. it's less find and more know. notice it took me a bit to add the name of the keybind
(and if not know, knowing where to look)
 
4:32 PM
@RGS The code in an operator isn't used until the derived function is called. At that point, the operator code specifies how the operands should be used.
 
@ngn @dzaima Thanks very much guys! It definitely worked
 
RGS
@Adám ok. So what keeps me from seeing an operator as a dfn with 3 or 4 arguments?
 
@RGS Nothing. But of course, you'd never use function operands then.
 
RGS
@Adám how so?
my operator made use of ⍺⍺ and ⍵⍵
 
@ngn No it's funny, you were right. It wasn't set to what it is in other web browsers (or Chrome). It was F12... But system wide function key mappings override app-specific ones, so when I used it, I simply got the normal system-wide response
 
4:34 PM
@RGS Sure, but they are not functions, they are arrays.
 
RGS
ah! The point is that ⍺⍺ and ⍵⍵ can be functions
is that it?
and I cheated a bit and used arrays for ⍺⍺ and ⍵⍵?
 
@RGS Yes.
@RGS It isn't cheating. Plenty of primitive operators use array operands, and ⎕R/⎕S can even use only array operands.
 
RGS
Ok, thanks! Now I understand
So can I assume I completed the recursive task for Fib?
:-D
Let me ask a question on APL style: are guards well accepted?
 
@RGS You did.
@RGS Absolutely.
 
RGS
@Adám any specific usage to avoid?
 
4:39 PM
I don't think so. They are the basic flow control of dfns.
 
RGS
So APL isn't against flow control? :D
 
@RGS - A language that doesn't have flow control isn't Turing-complete
 
RGS
@JeffZeitlin I meant this specific type of flow control i.e. with guards
 
No, see, APL doesn't enforce a style upon you. You can go totally imperative, purely functional, object oriented,…
 
RGS
Alright, I just want to understand what usually goes well/better with APL's array-oriented way of being
 
4:42 PM
@RGS control flow is okay when you're actually controlling program flow, of course you should prefer using array operations where you don't need short-circuiting
 
@Adám given otherwise equivalent tail-recursive and power-operator pieces of code, is one more efficient than the other?
Or a tradfn :While?
 
@xpqz simple test. of course, it may vary depending on the function
 
5:05 PM
Hmm. My experience so far has been that recusion is slow(er), but maybe it's if you build up a large accumulator as the ⍺-side of the ∇ call? I way back when wrote a lot of Scheme, and I instinctively reach for recursion. To me, dfns feel very "Scheme-y".
 
@xpqz - I sorta got the impression that even 1960s APL sorta encouraged recursive code.
 
@xpqz tail-call recursion is pretty much equivalent to while loops, and it seems Dyalog performs better on recursion
 
The slowness I've experienced so far had one factor in common: me.
 
RGS
@xpqz that was funny xD
 
I'm here all week :P
 
5:10 PM
a bit more testing with the compiler
 
/me chuckles. "The slowest part of the computer is between the chair and the keyboard."
 
 
1 hour later…
6:25 PM
@xpqz I don't know if it is possible to make generalisations on that. Why not do ]runtime -compare?
 

« first day (1182 days earlier)      last day (1478 days later) »