Also, this works:

   *:+/1 2 3 
36

So define:

   ss=: 13 :'*:+/y'
   ss
[: *: +/

This is probably the simplest tacit expression.
   

   ([: *: +/) 1 2 3
36

Linda

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Roger Hui
Sent: Tuesday, November 08, 2011 7:43 PM
To: Programming forum
Subject: Re: [Jprogramming] Why does my function composition fail?

Without parens, *:@:+/ is interpreted as (*:@:+)/.  You need to say *:@:(+/).

The various forms of display can be helpful.  On the main menu,
Edit|Config|Display Form.  If all display forms are selected, you get:

   sqsum =: *: @: +/
   sqsum
*:@:+/
┌─────────┬─┐
│┌──┬──┬─┐│/│
││*:│@:│+││ │
│└──┴──┴─┘│ │
└─────────┴─┘
             ┌─ *:
── / ─── @: ─┴─ +
(*:@:+)/


   sqsum1 =: *: @: (+/)
   sqsum1
*:@:(+/)
┌──┬──┬─────┐
│*:│@:│┌─┬─┐│
│  │  ││+│/││
│  │  │└─┴─┘│
└──┴──┴─────┘
       ┌─ *:
── @: ─┴─ / ─── +
*:@:(+/)




On Tue, Nov 8, 2011 at 4:36 PM, Don Nguyen <[email protected]> wrote:
> I have the following function
> sqsum =: *: @: +/
> When I use it as follows
> sqsum 1 2 3
> It produces 676 whereas the correct output should be
> *: (+/ 1 2 3)
> =36
> What have I done wrong?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
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