-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need an Ivy discussion forum to ask user questions - e.g. where Alpha and Omega commands? #28
Comments
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 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. |
Based on a suggestion by Alan Davies (glxxyz on GitHub), and borrowing heavily from Dyalog's guards, implement conditional evaluation. The new construct looks like a binary operator ":", but is of lower precedence than any other operator. It is enabled only inside user-defined functions, and has the property that if the left-hand operand is non-zero, the function returns the right-hand operand. Otherwise, the right-hand operand is not evaluated and execution continues. It is an error if the left-hand operand is not a scalar. This has been a long time coming, so thanks to Alan for planting the seed, life for giving me a free day to think about how to do it, and especially to GitHub user jojomoore2007, who found a way to write a recursive function that is so amazing and yet abusive it pushed me over the edge. Example from testdata/function.ivy: # Recursive factorial. op fac n = n <= 1 : 1 n * fac n - 1 # Recursivd gcd. op a gcd b = a == b: a a > b: b gcd a-b a gcd b-a fac 10 3628800 1562 gcd fac 11 22 Fixes #65 Update #28
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. |
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 By the way, sincere gratitude for creating this wonderful piece of software!! A bit of background why I prefer not panickingI actually want to use ivy as a script language embedded in a Go programme.
I was initially thinking of using https://github.com/pkujhd/goloader to allow operators to write in Go, but hacking Go's linker seems to fragile. |
Why does
I was expecting
which is also what's returned by https://tryapl.org/ with the expression Below is my investigation
|
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 I tried the expression
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. |
@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
The text was updated successfully, but these errors were encountered: