On Thu, Aug 23, 2012 at 12:34 PM, Skip Cave <s...@caveconsulting.com> wrote:
> What I was trying to do was emulate a standard sequence function in Octave
> which has the following syntax:
>>> e:i:s
> ans = 5.00000 5.25000 5.50000 5.75000 6.00000 6.25000 6.50000 6.75000
> 7.00000 7.25000 7.50000 7.75000 8.00000
>
> In our Machine Learning homework we use this sequence-generating function
> often, so I thought I would see if I could duplicate the function in J.
> However, to fit J's dyadic syntax, I put s & e as the left argument of the
> function, and the increment i as the right argument. If you feel that there
> is a better way to place the three args around the dyadic function, feel
> free to propose that.

If you are trying to duplicate the Octave mechanism, I would preserve
the relative argument order that Octave uses, in other words one of
these:
   seqmonad e,i,s
   e seqdyad  i,s
   (e,i) seqdyad s
   e i seqadverb s

If I expected to frequently be using literal numeric arguments, I
would probably go with the first version.  Perhaps:

   seq=: [: +`(*i.)/ _1&}. , 1 <.@+ 1&{ %~ {:-{.

   seq 5 0.25 8
5 5.25 5.5 5.75 6 6.25 6.5 6.75 7 7.25 7.5 7.75 8

FYI,

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

Reply via email to