Also,

's e i'=:5 8 0.27
   
   i (],(+{:))^:((e-i)>:{:@])^:_ s
5 5.27 5.54 5.81 6.08 6.35 6.62 6.89 7.16 7.43 7.7 7.97
   
   s+ i* i.1+ <.(e-s)%i
5 5.27 5.54 5.81 6.08 6.35 6.62 6.89 7.16 7.43 7.7 7.97
   

Linda

-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of R.E. Boss
Sent: Friday, August 24, 2012 4:22 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Generating a sequence


      's e i'=. 5 8 0.25

   i (],(+{:))^:((e-i)>:{:@])^:_ s
5 5.25 5.5 5.75 6 6.25 6.5 6.75 7 7.25 7.5 7.75 8

   i=.0.27
   i (],(+{:))^:((e-i)>:{:@])^:_ s
5 5.27 5.54 5.81 6.08 6.35 6.62 6.89 7.16 7.43 7.7 7.97

I'm no 'tacitus', so that part I leave to the reader.


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: programming-boun...@forums.jsoftware.com 
> [mailto:programming-boun...@forums.jsoftware.com] Namens Raul Miller
> Verzonden: donderdag 23 augustus 2012 20:57
> Aan: programm...@jsoftware.com
> Onderwerp: Re: [Jprogramming] Generating a sequence
> 
> 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

----------------------------------------------------------------------
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