[Jprogramming] Tacit argument checking

Kip Murray km at math.uh.edu
Wed May 27 10:00:21 HKT 2009


So you can.  That's better.

Sherlock, Ric wrote:
> 
>> From: Kip Murray
>>
>> I found system verb assert in ~system\main\stdlib.ijs and learned how to
>> use it from Roger's The
>> Ball Clock Problem below.  Here is my final exam paper:
>>
>>     NB. From ~system\main\stdlib.ijs
>>     NB. =========================================================
>>     NB.*assert v assert value is true
>>     NB. assertion failure if  0 e. y
>>     NB. e.g. 'invalid age' assert 0 <: age
>>     assert=: 0 0"_ $ 13!:8^:((0: e. ])`(12"_))
>>
>>     string =: 'domain error: arguments must be >0 and not _ '
>>
>>     f =: (^. [ string"_ assert 0&< *. _&>)"0 :[:
>>
>>     NB. Because of [ the result is ^. y provided the assert succeeds
>>
>>     f 1 2 3
>> 0 0.693147 1.09861
> 
> 
> Can use NVV fork:
> 
> f2 =: (^. [ string assert 0&< *. _&>)"0 :[:
>    f2 1 2 3
> 0 0.693147 1.09861
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list