Skip to content
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

Cannot derive monadic operator from inner product with right operand. #10

Open
rodrigogiraoserrao opened this issue Oct 8, 2021 · 0 comments
Labels
bug Things not working as they should.

Comments

@rodrigogiraoserrao
Copy link
Contributor

rodrigogiraoserrao commented Oct 8, 2021

>>> import operator
>>> from pynapl import APL
>>> apl = APL.APL()
>>> dot_ = apl.op(".+")
>>> dot_(operator.mul)([1, 2, 3], [1, 2, 3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\rodri\Documents\Dyalog\pynapl\pynapl\APLPyConnect.py", line 307, in __fn
    if len(args)==2: return self.eval("(⊃∆)(%s)2⊃∆"%aplfn, args[0], args[1], raw=raw)
  File "C:\Users\rodri\Documents\Dyalog\pynapl\pynapl\APLPyConnect.py", line 381, in eval
    raise APLError(json_obj=reply.data)
pynapl.APLPyConnect.APLError: SYNTAX ERROR

The expected behaviour would've been to compute 1 2 3 ×.+ 1 2 3. Instead, we get a SYNTAX ERROR.
This does not seem to be a shortcoming of dyadic operators in general, as we seem to be able to derive monadic operators from other dyadic operators; @ for example:

>>> from pynapl import APL
>>> apl = APL.APL()
>>> # Array right operand
>>> at_first = apl.op("@1")
>>> at_first(lambda *_: 73)([1, 2, 3, 4])
[73, 2, 3, 4]
>>> at_first(lambda n: n + 3)([1, 2, 3, 4])
[4, 2, 3, 4]
>>> # Function right operand
>>> at_self = apl.op("@⊢")
>>> at_self(lambda *_: 73)([1, 0, 1, 0, 0, 1, 1])
[73, 0, 73, 0, 0, 73, 73]

Probably related to the special casing mentioned in #9.

@rodrigogiraoserrao rodrigogiraoserrao added the bug Things not working as they should. label Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things not working as they should.
Projects
None yet
Development

No branches or pull requests

1 participant