Yup, you're quite right.
Should've been
nPr =: [:*/(-i.)
I'll go give ch.6 of jfC a look now...
On Fri, 2010-02-19 at 18:50 -0500, Henry Rich wrote:
> You must not have executed something:
>
> nPr =: [:*/-i.
>
> always fails with a domain error.
>
> ([:*/-i.)
>
> is
>
> [: (*/ - i.)
>
> is
>
> y [: (x */ y) - (x i. y)
>
> which is not useful.
>
> */@(-i.)
>
> is
>
> */ x (-i.) y
>
> is
>
> */ x - i. y
>
> which is permutation.
>
> For a discussion of rank, I like chapter 6 of JfC, which you can get to
> from the help page -- but I would, because I wrote it.
>
> Henry Rich
>
>
> Alex Gian wrote:
> > Although, funnily enough if we define
> > nPr =: [:*/-i.
> > then it works
> > 14 nPr 1.9
> > 1 14 182 2184 24024 240240 2162160 17297280 121080960
> >
> > I'm beginning to understand the issue with the rank, although it seems
> > to me that "*/@(-i.)" and "[:*/-i." are not a million miles from each
> > other, so I can't quite see _which_ is the verb that allows the one to
> > work, but not the other.
> >
> > Can anyone point me to the best introduction to read about verb rank?
> >
> >
> > (BTW, I do understand that if we want the whole sequence
> > */\ 14 - i. 8
> > is the better way, since it will avoid redundant recomputation.)
> >
> >
> >
> > On Fri, 2010-02-19 at 13:12 +0100, Zsbán Ambrus wrote:
> >
> >> The way we defined that verb, it won't automatically work for an array
> >> of numbers. J builtins that do numerical computations on single
> >> numbers are defined to be extended to arrays. For example, ^!._1 is
> >> such a builtin, so we get
> >>
> >> 14 ^!._1 i. 9
> >> 1 14 182 2184 24024 240240 2162160 17297280 121080960
> >>
> >> Other builtins and user functions do use array arguments as a whole,
> >> so J won't automatically apply our defined verbs to each element,
> >> which is why the above doesn't work. You can use the rank conjuction
> >> to apply them to each element and assemble the results.
> >>
> >> 14 */@(-i.)"0 i. 9
> >> 1 14 182 2184 24024 240240 2162160 17297280 121080960
> >>
> >> Although if you need the whole sequence, it might be better to compute
> >> it like this,
> >>
> >> 1, */\ 14 - i. 8
> >> 1 14 182 2184 24024 240240 2162160 17297280 121080960
> >>
> >> Ambrus
> >
> >
> >
> > ----------------------------------------------------------------------
> > 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