2006/9/27, Henry Rich <[EMAIL PROTECTED]>:
[snip]

 h^:(]`(<:@[)`])   g



Yeah! That's it. I easily forget that there is the gerund cases for
power, too. Thank you, Henry.


Henry Rich

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Yuvaraj Athur Raghuvir
> Sent: Tuesday, September 26, 2006 11:45 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Exploring Reflex & How to factor
> out the argument
>
> By "pass the parameter y to the function f before it is
> applied", I mean the
> following effect -
> (gy) (fy) (gy).
>
> Since I was trying to use the power function to repeat the
> verb, I wanted to
> control the number of times externally. For example,
>
> (gy) (h^:<:y) (gy) would then expand to :
>
> (gy) h (gy) .... (y-1) times... (gy) h (gy)
>
> So, I would like to define
> f =. h^:<:
>
> Then I want to pass y to f to indicate number of application
> of h between
> (gy).
>
> ~Yuva
>
> p.s: In my example below,
> h =. ,
>
>
> On 9/27/06, Roger Hui <[EMAIL PROTECTED]> wrote:
> >
> > (g y) f (g y) is indeed the same as  (f~@:g) y
> >
> > What does "pass the parameter y to the function f
> > before it is applied" mean?  For example, does it
> > mean   y f (g y) ?
> >
> >   (# ,:@i.) 5
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> >   (,~ $ i.) 5
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> >   (| i.@,~) 5
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> > 0 1 2 3 4
> >
> >
> >
> > ----- Original Message -----
> > From: Yuvaraj Athur Raghuvir <[EMAIL PROTECTED]>
> > Date: Tuesday, September 26, 2006 8:10 pm
> > Subject: [Jprogramming] Exploring Reflex & How to factor
> out the argument
> >
> > > Hello,
> > >
> > > I am not sure if I understand the '~' (reflex) adverb right.
> > >
> > > 1) Is the following true?
> > > (f~ @: g)y is the same as  (gy) f (gy).
> > >
> > > 2) Now, I want to pass the parameter y to the function f
> before it is
> > > applied. Is that possible?
> > >
> > > Regards,
> > > Yuva
> > >
> > > Example: (absolute beginner exploration...optimal versions are
> > > welcome!)
> > >   NB. create a n by n matrix with 0 to (n-1) repeated n times
> > >   n =. 3
> > >   NB. solution1: ravel the laminations n-1 times
> > >   (,: i.n) ,^: (<:n) (,: i.n)
> > > 0 1 2
> > > 0 1 2
> > > 0 1 2
> > >   NB. hmmm... looks like the n can be factored out...
> > >   NB. I see a reflex form, and then a power....
> > >   NB. so,
> > >   sol1 =: (,^: (<:])~) @: (,: i.)
> > >   $ sol1 n
> > > 2 3 4 3
> > >   NB. Oops! The n has not reached the inner function. Is the form
> > > right??
> > >   NB. Another way using transpose....
> > >   sol2 =. |: @: (#"0 i.)~
> > >   sol2 n  NB. works as intended
> > > 0 1 2
> > > 0 1 2
> > > 0 1 2
> >
> >
> >
> ----------------------------------------------------------------------
> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to