noob question about pow

For users of dfns, both novice and expert

noob question about pow

Postby Yves on Wed Aug 22, 2018 6:29 pm

Dear All,
i start to use recursive D-fns, and i try sample in immediate selfhelp (F1).

on recursive page, i understand fact function.

but for pow function, i dont understand. it illustrate ∇∇ and use only ∇.
what's the crumble ?

other points : i paste in APL session, and it do an error :
      pow←{             ⍝ Function power.
⍺=0:⍵ ⍝ Apply function operand ⍺ times.
(⍺-1)∇ ⍺⍺ ⍵ ⍝ ⍺⍺ ⍺⍺ ⍺⍺ ... ⍵
}
2 pow 5
VALUE ERROR
pow[1] ⍺=0:⍵ ⍝ Apply function operand ⍺ times.

pow 5
SYNTAX ERROR
pow 5
i dont understand what can i do.
i am lost outer space. can you help me to contact Houston ?

Great Thanks,
Yves
Yves
 
Posts: 39
Joined: Mon Nov 30, 2015 11:33 am

Re: noob question about pow

Postby Veli-Matti on Thu Aug 23, 2018 6:07 am

Welcome to the world of operators :)
In this case you need a function as the left operand.
Perhaps this gives some ideas:
      ⍟⍟⍟⍟ 5000
¯0.2720968003
4 ⍟ pow 5000
¯0.2720968003


-Veli-Matti
Veli-Matti
 
Posts: 94
Joined: Sat Nov 28, 2009 3:12 pm

Re: noob question about pow

Postby Yves on Fri Sep 21, 2018 4:51 pm

Dear -Veli-Matti,
Great thanks for your help.

      'bee' ⎕wc 'form' ( 'coord'  'pixel' )
bee.AcceptFiles ← 1
bee.onDropFiles ← 'AffMsg'
┌→───────────────────────────────────────────────────────────┐
│ ┌→────────┐ ┌→────────────────────────────────┐ │
│ #.bee │DropFiles│ │ ┌→────────────────────────────┐ │ ¯1 0 │
│ └─────────┘ │ │C:\Users\user\Desktop\yes.dws│ │ │
│ │ └─────────────────────────────┘ │ │
│ └∊────────────────────────────────┘ │
└∊───────────────────────────────────────────────────────────┘

how to catch path simply with never error ? (i do always mistake or error)
      disp 1↑ 2↓ chn
┌→────────────────────────────────────┐
│ ┌→────────────────────────────────┐ │
│ │ ┌→────────────────────────────┐ │ │
│ │ │C:\Users\user\Desktop\yes.dws│ │ │
│ │ └─────────────────────────────┘ │ │
│ └∊────────────────────────────────┘ │
└∊────────────────────────────────────┘

usualy, i handcraft a trashable and piggy code.
Now, with your help, i do this :
      disp { (≡⍵) (⊃,/) pow ⍵ } 1↑ 2↓ chn
┌→────────────────────────────┐
│C:\Users\user\Desktop\yes.dws│
└─────────────────────────────┘

possible my solution is not the better solution.
i appreciate yours comments on it.
Yves
Yves
 
Posts: 39
Joined: Mon Nov 30, 2015 11:33 am

Re: noob question about pow

Postby Michael|Dyalog on Sat Sep 22, 2018 6:26 pm

Bonjour Yves ;-)

let me help to make it shorter:
with msg=
Code: Select all
┌→────────────────────────────────────────────────────────┐
│       ┌→────────┐ ┌→─────────────────────────────┐      │
│ #.bee │DropFiles│ │ ┌→─────────────────────────┐ │ ¯1 0 │
│       └─────────┘ │ │c:\User\desktop\yves.dws\)│ │      │
│                   │ └──────────────────────────┘ │      │
│                   └∊─────────────────────────────┘      │
└∊────────────────────────────────────────────────────────┘


you can also do this:
Code: Select all
      3 1⊃msg
┌→─────────────────────────┐
│c:\User\desktop\yves.dws\)│
└──────────────────────────┘
Last edited by Michael|Dyalog on Tue Sep 25, 2018 3:12 pm, edited 1 time in total.
Michael|Dyalog
 
Posts: 23
Joined: Thu Mar 02, 2017 4:29 pm

Re: noob question about pow

Postby Yves on Tue Sep 25, 2018 2:08 pm

Dear Michael & All,
Many Thanks for your help.

Before, i use only array with indexing.
Now, i see difference between them.
      ]display str ← 'abc'  'def'  'ghi'
┌→──────────────────┐
│ ┌→──┐ ┌→──┐ ┌→──┐ │
│ │abc│ │def│ │ghi│ │
│ └───┘ └───┘ └───┘ │
└∊──────────────────┘
]display 2 ⊃ str
┌→──┐
│def│
└───┘
]display str[ 2 ]
┌───────┐
│ ┌→──┐ │
│ │def│ │
│ └───┘ │
└∊──────┘


Thank you so much Michael
Guten Tag :-)
Yves
 
Posts: 39
Joined: Mon Nov 30, 2015 11:33 am


Return to Functional Programming

Who is online

Users browsing this forum: No registered users and 1 guest