Changing either if. or assert. would break lots of code, so there's no prospect of making everything consistent.  (And I think the current definitions are the best ones anyway.)

The code for assert. uses  (1 *./@:= ])  which I think is the same as what Igor suggested.  About whether it's worth changing I have no opinion.

Henry Rich

On 12/30/2019 5:23 AM, Ric Sherlock wrote:
I agree that the behaviour of the two should match, but am not sure what
the desired definition should be. The Nuvoc page for the assert. keyword
says that the entire list must be 1s, which at one level makes sense to me,
however the test for if. is that the 1st item of the array is nonzero and
the nonzero condition is consistent with the definition of assert in
stdlib. Should they all be consistent though?



On Mon, 30 Dec 2019, 13:43 Igor Zhuravlov, <[email protected]> wrote:

stdlib has the definition:
    assert=: 0 0 $ 13!:8^:((0 e. ])`(12"_))
which accepts a wrong input e.g.
    assert 1 2 1
                        NB. an error expected, not an empty output

This definition may be fixed as:
    assert=: 0 0 $ 13!:8^:((1 +./@:~: ])`(12"_))
to match (assert.) control behavior:
    assert 1 2 1
|assertion failure: assert
|       assert 1 2 1

--
Regards,
Igor


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