powerset

Keith Wansbrough Keith.Wansbrough@cl.cam.ac.uk
Thu, 05 Jun 2003 16:20:36 +0100


> >   You (Graham) also have
> >some parentheses issues; e.g. in foo ++ (combinations 5 l) the
> >parentheses are superfluous.
> 
> I'm tempted to argue that being superfluous doesn't mean they shouldn't be 
> there.  This isn't just a functional programming issue... I find that when 
> there are many levels of operator precedence it's easier to be explicit 
> than to try and remember what they all are -- as much for reading the code 
> as writing it in the first place.  But maybe I'm still reading functional 
> code in the wrong way?  (I still scratch my head over some of the 
> prelude/library functions, though it's getting easier.)

This is a particular instance where you never need the
parentheses... since it's a _functional_ language, _function
application_ (the invisible symbol between combinations and 5, and
between combinations 5 and l) binds tighter than anything else.  The
only time you need parentheses around a function application are when
it is to protect it from a competing function application, such as
when you are passing it as an argument to a function:

  map (map f) xss    rather than   map  map f  xss

HTH.

--KW 8-)