Hi Brian, the [ shouldn't be required. I think I left it in there when
I was initially building it... For example, paste this into a new
session:


func=: 3 : 0
doc=.  (y,'_doc')=: 0 : 0
lines=.dlb each LF cut doc
0!:0 > {: lines
examples=. (y,'_examples')=:3 }. each (#~ (<'ex:') E. 3 {. each [) lines
for_ex. examples do.
    ex=.(>ex)
    try.
        assert ". ex
    catch.
        smoutput ex , ' failed'
        smoutput 'returned '
        smoutput ". ex
    end.

end.
''
)

func 'add1'
    adds 1 to the input
    ex: 6 = add1 5
    ex: 7 = add1 5 NB. show the failing test
    add1=:1 + ]
)

   add1 5
6

You will also see the output of the failing test when you initially
paste/run the script, but not on subsequent invocations of add1


On Sun, Dec 6, 2015 at 11:14 AM, Brian Schott <schott.br...@gmail.com> wrote:
> What verb initializes all the calls
> like func '...'?
>


func is a verb, and so it operates immediately on the argument when
the script is loaded.

It works much like Note (which was my inspiration for it)

   Note
3 : '0 0 $ 0 : 0' :[
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to