Jsoftware
High-Performance Development Platform

Negative Indices

View: New views
3 Messages — Rating Filter:   Alert me  

Negative Indices

by Leigh J. Halliwell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear J Forum,
 
I'm working with an array of n items.  It's possible for my index to be _1;
but then I'd like _1 { array to generate an error, rather than to select the
last item.  Is there any "clean/elegant" way to do this, i.e., with just
using '{' and no conditional statements?  I might have a similar problem
with i. _1.  Thanks.
 
Sincerely,

Leigh


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

Re: Negative Indices

by Raul Miller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Aug 29, 2008 at 9:19 AM, Leigh J. Halliwell
<leigh@...> wrote:
> I'm working with an array of n items.  It's possible for my index to be _1;
> but then I'd like _1 { array to generate an error, rather than to select the
> last item.  Is there any "clean/elegant" way to do this, i.e., with just
> using '{' and no conditional statements?  I might have a similar problem
> with i. _1.  Thanks.

You could use >.&_0.5 on your indices.

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

RE: Negative Indices

by Leigh J. Halliwell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you, Raul.  I should have thought of that.  Neat and clever.

Leigh

-----Original Message-----
From: programming-bounces@...
[mailto:programming-bounces@...] On Behalf Of Raul Miller
Sent: Friday, August 29, 2008 9:29 AM
To: Programming forum
Subject: Re: [Jprogramming] Negative Indices

On Fri, Aug 29, 2008 at 9:19 AM, Leigh J. Halliwell
<leigh@...> wrote:
> I'm working with an array of n items.  It's possible for my index to be
_1;
> but then I'd like _1 { array to generate an error, rather than to select
the
> last item.  Is there any "clean/elegant" way to do this, i.e., with just
> using '{' and no conditional statements?  I might have a similar problem
> with i. _1.  Thanks.

You could use >.&_0.5 on your indices.

--
Raul

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
LightInTheBox - Buy quality products at wholesale price!