a better version of assert
assert2 =: ]`([ 13!:8 (12"_))@.(0 e.])
assert 3 4 NB. returns nothing
assert 3 4 0
|assertion failure: assert
'bad' assert 3 4 0
|bad: assert
| 'bad' assert 3 4 0
what makes assert2 useful is that it raises an error if result includes 0 (can
also be easily defined to also raise if count = 0 ie. null/empty) but it
otherwise returns the result instead of returning nothing.
This allows tacit (or any) code, to further process the result.
'bad' assert2 3 4
3 4
'bad' assert2 3 4 0
|bad: assert2
| 'bad' assert2 3 4 0
----- Original Message -----
From: Michael Berry <[email protected]>
To: [email protected]
Sent: Tuesday, October 4, 2016 5:43 PM
Subject: [Jprogramming] assert and assert.
Is there something I can read to understand the difference between the
control structure assert. and the standard library function assert and when
one or the other might be preferable?
-Michael
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm