> From: Roger Hui
>
> If you prefer to define a function
> using compositions (i.e. "tacitly"), then:
>
> f1=: % @: (+/) @: %
>
> is better.
Note an alternative form of the above (using forks) is:
f1a=: [: % [: +/ %
I know that I found that form easier to grasp when I was first coming to grip
with tacit.
The following links may be of some help.
http://www.jsoftware.com/jwiki/Guides/Defining%20Verbs
http://www.jsoftware.com/jwiki/Guides/Reading%20Tacit%20Verbs
>
> ----- Original Message -----
> From: Alex Gian <[email protected]>
> Date: Wednesday, February 3, 2010 16:36
> Subject: [Jprogramming] A q for starters - composing without forking (%
> +/ %)
> To: [email protected]
>
> > Hi - complete newbie to J here. Though I like what I've seen so far.
> >
> > Here's my starter question:
> > I'd like to code the function that gives the inverse of a sum of
> > inverses (eg. like when calculating resistors in parallel)
> >
> > It works fine if I just write it out as
> > % +/ % 10 20
> > 40 (ans 5.71429)
> >
> > However, if I try to make a function of it,
> > invsuminv =. % +/ %
> > it becomes a fork (I guess that _does_ make sense), and just computes
> > the "cross-sum" of the inverses, as if I'd typed
> > (%
> > +/ %) 10 20 40
> > 0.2
> > 0.15 0.125
> >
> > 0.15 0.1 0.075
> > 0.125 0.075 0.05
> >
> > How can I avoid this? I've tried all sorts of combinations,
> > using @ and
> > & but can't seem to crack it. Obviously something
> > fundamental I'm not
> > grasping. Any help appreciated.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm