Hi Mike
You request comments regarding style. Style is a matter of taste, so don't take 
my comments as criticism. 
Your very first expression 

   (n%2)>(]?]) n$d
can be written without division:

   n>+:(?])n#dThe value depends on two variable, n and d, and so you may create 
a dyadic verb, focusing attention on functions rather than on variables.
   n( 4 : 'x>+:(?]) x#y')d

or, using tacit code:
   n([>[:+:[:(?])#)d


Your questions:

1) how do I avoid @ especially once we remove explicit arguments?
- by using cap. ([:)


4) Is there a good way to have named variables (ie. avoid getx, gety)?
replace
   getx   =: 0{ ]
   gety   =: 1{ ]
   revDom =: getx *. +./ @ (gety # [)
with
   revDom =: (0{ ]) *. +./ @ ((1{ ]) # [)


5) Why is a hook the default and not composition?
- Because J'ers love hooks! For composition use the capped fork ([: f g)

-Bo



>________________________________
> Fra: Michal D. <michal.dobrog...@gmail.com>
>Til: programm...@jsoftware.com 
>Sendt: 6:01 fredag den 2. november 2012
>Emne: [Jprogramming] Arc consistency in J
> 
>Hi All,
>
>I've managed to write my first not-completely-trivial program in J.  It
>implements an arc consistency algorithm (
>http://en.wikipedia.org/wiki/Local_consistency#Arc_consistency).  I would
>appreciate any comments regarding style, what I'm doing wrong in J or how
>to improve the code.  I also have a couple of questions of my own:
>
>1) how do I avoid @ especially once we remove explicit arguments?
>2) how do I avoid constant boxing/unboxing due to fill (see arcsX)?
>3) Is a boxed value always a pointer? One could imagine implementing
>'ragged' arrays without pointers.
>4) Is there a good way to have named variables (ie. avoid getx, gety)?
>5) Why is a hook the default and not composition?
>
>Code at: http://pastebin.com/k4XuKfFi
>
>Cheers!
>
>Mike
>----------------------------------------------------------------------
>For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to