[Jprogramming] assert verb from stdlib mismatches assert. control
Ric Sherlock
tikkanz at gmail.com
Mon Dec 30 10:23:01 UTC 2019
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, <zhuravlov.ip at ya.ru> 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
>
More information about the Programming
mailing list