1. To debug a sentence, use Dissect. 2. To print expressions during execution, a quick way is
load'printf' NB. just once per session qprintf'x ' qprintf'x $y ' The last character of the argument is the delimiter between expressions. Henry Rich On 1/27/2022 8:23 AM, Pawel Jakubas wrote:
Dear J enthusiasts, I am defining `x repeat y` function, that is appending y to itself x times. And defined something like below (on intention like that to ask a couple of questions). f=: 4 : 0 assert (x < 10) segment=.>0{y if. (x = 1) do. (>1{y) else. (x-1) f (segment;( (>1{y),segment) ) end. ) d 1 2 3 1 f (d;d) 1 2 3 2 f (d;d) 1 2 3 1 2 3 3 f (d;d) 1 2 3 1 2 3 1 2 3 1. Is there a way to customize assert message. So instead of 11 f (d;d) |assertion failure: assert | assert(x<10) have for example message "only x less than 10 is accepted" 2. How to introduce debugs? For example I would like to print x as f executes 3. Do we have by the way `repeat` in J as I try to define? 4. I intentionally defined f like above as it needs (d;d) as y. Let's assume I want higher level `repeat` dyad that is x repeat d and defines inside `f` dyad as above and calls it x f (d;d) What are good practices to to separate x,y from repeat and not to mix them in the defined function f (ie. have them decoupled). Thanks in advance and cheers, Pawel ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
-- This email has been checked for viruses by AVG. https://www.avg.com ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm