Open benjamin-rood opened 8 years ago
You can't, at least not yet. Ivy is far from a complete mapping of APL's features, even APL\360. I believe the more powerful versions α and ω came much later, perhaps in APL2. I'm not sure.
Of course you can always define a unary or binary operator and name the arguments yourself; there are examples in the ivy help text. But looping and conditionals are not available.
I may do something about that one day but have no plans to do so.
Thanks for the response. I wonder how one could do a recursive gcd operator then without conditionals? Ultimately I wanted to try to implement a binary coprime operator where op x coprime n
produces a vector with all natural numbers ≤ n which are coprime to x.
I do appreciate that as you say, this is a plaything. I very much enjoyed the implementation in Go presentation and I learnt a lot from it, so thank you.
I noticed this is still open, presumably because of the 'need an Ivy discussion forum' part since the conditional execution now exists. One possibility would be to enable GitHub Discussions on this repo. We've used them for Go discussions that are expected to be too much for the issue tracker, and the single level of threading is really helpful.
We tend to only use them for big things in Go, but projects often use them now for Q&A etc. https://github.com/golang/go/discussions/47141 is one of our smaller discussions.
Could do that. It hasn't really had enough users to be worth doing until you started posting all these power-user videos :)
Could we not panic in value.Errorf
?
In particular, value.index
already does bounds checking, so repanicking seems wierd.
By the way, sincere gratitude for creating this wonderful piece of software!!
Why does (5 5 rho iota 25)[3 2; 1 2 3]
return the following?
11 12
13 6
7 8
I was expecting
11 12 13
6 7 8
which is also what's returned by https://tryapl.org/ with the expression (5 5 ⍴ ⍳ 25)[3 2; 1 2 3]
.
value.Errorf
panics because that is how the interpreter does error recovery. it's an easy way to do exception handling. Otherwise the control flow from deep in the interpreter during a calculation would require threading errors through a vast collection of code.
It's common for language implementations and related systems to work like this.
Regarding the indexing example, that's the usual APL way, as you can see by trying the example on https://tryapl.org/. The vector left of the semicolon selects the first axis, while the vector on the right selects the second.
@robpike thanks for your explanation and for sharing your experience in language and systems implementation. I have few experience in language and systems implementation, so it's enlightening to learn that panic
and recover
can be useful in these circumstances.
I tried the expression (5 5 ⍴ ⍳ 25)[3 2; 1 2 3]
in https://tryapl.org/ , and it returned
11 12 13
6 7 8
I guess it makes sense for ivy to return this, too?
Oh, fair point. I misread your issue.
@rsc did the rewrite that got us here so over to him.
@fumin @robpike I opened #111 for the indexing question.
I noticed this is still open, presumably because of the 'need an Ivy discussion forum' part since the conditional execution now exists. One possibility would be to enable GitHub Discussions on this repo. We've used them for Go discussions that are expected to be too much for the issue tracker, and the single level of threading is really helpful.
We tend to only use them for big things in Go, but projects often use them now for Q&A etc. golang/go#47141 is one of our smaller discussions.
@rsc this can be moved to disucssions now ?
Hi Rob, sorry to bother you here, but I don't see how in Ivy you can use the APL α and ω commands, e.g. if I wanted to create a gcd operator like so:
src: http://dfns.dyalog.com/n_gcd.htm