Skip to content

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

@rodrigogiraoserrao

Description

@rodrigogiraoserrao
>>> 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThings not working as they should.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions