I'm not able to understand compose operator in APL.
I have tried but precedence is the issue that I am facing.
I assume that by compose operator you mean f∘g
(where f
and g
are functions) which Dyalog 18.0 renamed from the general name Compose to the more specific name Beside. X f∘g Y
(where X
and Y
are arrays) is equivalent to X f g Y
, and f∘g Y
is equivalent to f g Y
.
f∘g
is a derived function and so is subject to the same precedence as all other APL functions (i.e. long right scope). The binding rules might trip you up if g
is itself a derived function. E.g. if f←-
and g←+/
then f∘g¨ (3 1 4 1 5)(2 7 1 8)
gives ¯14 ¯18
because it is the negation of the sum of each list. However, if you try to insert the definitions of f
and g
into f∘g
so you have -∘+/¨ (3 1 4 1 5)(2 7 1 8)
, you instead get 10 ¯12
. This is because -∘+/
binds as (-∘+)/
rather than -∘(+/)
due to operators having long left scope.
In conclusion, try to use parentheses to clarify how you want things to bind. If this doesn't help, then amend your question with more details of what you're trying to do.