> I take it that picking # over $ is a purely stylistic preference.

"#" returns a scalar and "$" returns a vector.  Each of these applied
monadically to a vector will give the same number but applied to anything
of lower or higher dimension will return different answers entirely.

   'a';'few';'words';<'squ',:'are'
+-+---+-----+---+
|a|few|words|squ|
| |   |     |are|
+-+---+-----+---+
   $ &> 'a';'few';'words';<'squ',:'are'  NB. Shape of each
0 0
3 0
5 0
2 3
   # &> 'a';'few';'words';<'squ',:'are'  NB. Tally of each
1 3 5 2


On Sun, Nov 4, 2012 at 12:31 AM, Michal D. <michal.dobrog...@gmail.com>wrote:

> Thank you everyone for the comments and encouragement.
>
> I think Bo's (?]) and accompanying code was an interesting illustration of
> a nice use of the hook.  I'm not sure why to prefer doubling an entire
> array as opposed to dividing a single scalar?  I think that inlining getx
> and gety is anti-style ;-).  See also all the argument unwrapping that
> happens in the new revise.  Too bad there is no way to prevent this.
>
> I take it that picking # over $ is a purely stylistic preference.  I
> appreciate all the comments regarding coppula and NB.*, both sound like a
> good idea.
>
> The historical comments regarding a hook conjunction exactly mirror my
> frustrations.  Thank you Raul also for arcsX2, that is a thing of beauty
> =).
>
> New and improved code at http://pastebin.com/fzs0GAev with an expanded
> intro to "CSPs".
>
> Cheers,
>
> Mike
>
> On Thu, Nov 1, 2012 at 10:01 PM, Michal D. <michal.dobrog...@gmail.com
> >wrote:
>
> > 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
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to