bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] A question.


From: Louis de Forcrand
Subject: Re: [Bug-apl] A question.
Date: Wed, 18 May 2016 16:23:32 +0200

⍶ is the left argument to a monadic or dyadic operator that takes
a function as an argument AND one or two actual arguments.
⍹ is the right (optional) second argument. Keep in mind that these
can also be data, not just a function.

A couple of other examples:
-foldleft  1 2 3 4 5 <—> 1-(2-(3-(4-5))) <—> ¯2
-foldright 1 2 3 4 5 <—> (((1-2)-3)-4)-5 <—> ¯8
If
foldleft←{⍶/⍵}
then
foldright←{⍶⍨/⌽⍵}
Since
⍶/⍵[1 2 3] <—> ⍵[1] ⍶ ⍵[2] ⍶ ⍵[3] <—> ⍵[1] ⍶ (⍵[2] ⍶ ⍵[3]),
then
⍶⍨/⌽⍵[1 2 3] <—> ⍶⍨/⍵[3 2 1] <—> ⍵[3] ⍶⍨ ⍵[2] ⍶⍨ ⍵[1]
<—> ⍵[3] ⍶⍨ ⍵[1] ⍶ ⍵[2] <—> (⍵[1] ⍶ ⍵[2]) ⍶ ⍵[3]

Derivative:
d←{((⍶⍵+⍺)-⍶⍵)÷⍺}
1E¯7 {⍵*2}d 3 <—> 6.000…
In conventional mathematical notation,
f'(x) = (f(x+h) - f(x)) / h
⍶d ⍵     ⍶ ⍵ ⍺    ⍶ ⍵     ⍺

Basically, the arguments are organised as
⍺ {} ⍵ for functions and ⍺ (⍶ {} ⍹) ⍵ for operators,
where your function/operator is in the {}.
⍺ and ⍵ cannot be functions, but ⍶ and ⍹ can.
⍺ and ⍹ are optional.

Best regards,
Louis

On 18 May 2016, at 05:39, Christian Robert <address@hidden> wrote:

Now pretty clear.

> It’s a definition for an operator receiving two function arguments ⍶ and ⍹, for which you can not do ⎕←⍹ or ⎕←⍶. ...

many thanks.

Xtian.

On 2016-05-17 23:12, Xiao-Yong Jin wrote:

On May 17, 2016, at 9:48 PM, Christian Robert <address@hidden> wrote:

Sorry, no explanations given.

    hook←{⍵⍶⍹⍵}
    +hook÷2
2.5
You can look at the definition
     ∇hook[⎕]∇
   ∇
[0]   λ←(⍶ hook ⍹ ) ⍵
[1]   λ←⍵⍶⍹⍵
   ∇
It’s a definition for an operator receiving two function arguments ⍶ and ⍹, for which you can not do ⎕←⍹ or ⎕←⍶.  The result is a monadic function with right argument ⍵.  Explicitly for the example,
     +hook÷2
is equivalent to
     2+÷2

    hook←{⍵⍶⍹⍵⊣⎕←⍵⊣⎕←⍶⊣⎕←⍹⊣⎕←⍵}
    +hook÷2
2
DOMAIN ERROR
hook[1]  λ←⍵ ⍶ ⍹ ⍵⊣⎕←⍵⊣⎕←⍶⊣⎕←⍹⊣⎕←⍵
                           ^^
please explain the principle to a newbie.

I really want a working examples.


Xtian.


On 2016-05-17 22:30, Xiao-Yong Jin wrote:
They are for direct function (operator?) definitions.  Try:

    hook←{⍵⍶⍹⍵}
    +hook÷2
2.5

On May 17, 2016, at 8:24 PM, Christian Robert <address@hidden> wrote:

hi,

in the result of "]help" I can see:


   λ       { ... } result
   ⍺       { ... } left value argument
   ⍵       { ... } right value argument
   χ       { ... } axis argument
   ⍶       { ... } left function argument
   ⍹       { ... } right function argument


can someone explain to me the usage of ⍶ and ⍹
with some examples ?

I understant the first four, but not the last two.

many thanks,

Xtian.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]