On Thu, Sep 8, 2011 at 12:47 PM, Steven Taylor <[email protected]> wrote:
> say I've got a verb train, that I like as a verb train... and I don't want
> to break it up.  Is there a way to check for an error condition?
>
>   3 (]{~ [ I.~]) i. 4
> 3
>
>   4 (]{~ [ I.~]) i. 4
> |index error
> |   4    (]{~[I.~])i.4
> |[-0]
>
> I could set an initial value like this...
>
>   fail=.0 [ret=. 4 { i.4  [ fail=.1
>
> i.e. fail should equal zero if   ret=.4 runs correctly.

   train=:     ]{~ [ I.~]
   iFailed=: do bind 'fail=:1'

   fail=: 0
   3 train ::iFailed i.4
3
   fail
0
   4 train ::iFailed i.4
1
   fail
1

FYI,

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

Reply via email to