Here's another way to get the dyadic result of g:

   g=: 13 :'x +&+: y'
   g 3
6
   2 g 3
10
   h=: 13 :'(+: x) + +:y'
   h 3
12
   2 h 3
10
   g
+&+:
   h
([: +: [) + [: +: ]

-----Original Message-----
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Sunday, March 02, 2014 11:03 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] bug in & ?

 

  f=: 13 :' +:&+&+: y'
   f
+:&+&+:
   f 3
12
   2 f 3
|domain error: f
|   2     f 3
   
   g=: 13 :'x +&+: y'
   g
+&+:
   
   g  3
6
   2 g 3
10

Now-Or applies to booleans:
   
   0 0 1 1 (+:"0) 0 1 0 1
1 0 0 0
   
Linda



-----Original Message-----
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Vijay Lulla
Sent: Sunday, March 02, 2014 10:52 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] bug in & ?

9!:3 [ 2 4

+&+&+:
┌───────┬─┬──┐
│┌─┬─┬─┐│&│+:│
││+│&│+││ │  │
│└─┴─┴─┘│ │  │
└───────┴─┴──┘
            ┌─ +
      ┌─ & ─┴─ +
── & ─┴─ +:

And looking at compose page (
http://www.jsoftware.com/help/dictionary/d630v.htm) we get

(+: 2) +&+ (+: 3)

I still don't understand the parsing rules enough to know how more
complicated expressions/trains get parsed by J.
Pardon if this is mere noise.


On Sun, Mar 2, 2014 at 10:33 AM, Pascal Jasmin <godspiral2...@yahoo.ca>wrote:

> That is indeed the problem, but the code
>
>  2  +&+&+: 3
>
>
> is not    2 + 2 +&+: 3
>
> but rather
>    0 + 2 +&+: 3
> 10
> when it should be:
>     + 2 +&+: 3
> 10
>
> There doesn't seem to be a good reason to insert 0 v in it.  This is weird
> though:
>
>      2 ([: +: ])&(+&+:) 3
> 12
>
> I don't think it is:
>
>  2+  2 +&+:3
>
> which seems to have nothing to do with supplied verbs. So more likely:
>
> +: (+ +: 3)
>
> and x argument is discarded completely. (it should have applied to 2 +&+:
> 3, and above result should be 20)
>
>
> ----- Original Message -----
> From: Don Guinn <dongu...@gmail.com>
> To: Programming forum <programm...@jsoftware.com>
> Cc:
> Sent: Sunday, March 2, 2014 10:02:31 AM
> Subject: Re: [Jprogramming] bug in & ?
>
> I think the problem is that the left-most +: is not-or and only accepts
> boolean arguments.
>
>    0 +:&+&+: 0
> 1
>
>
>
> On Sun, Mar 2, 2014 at 7:53 AM, Pascal Jasmin <godspiral2...@yahoo.ca
> >wrote:
>
> >     +:&+&+: 3
> > 12
> >    2  +&+&+: 3
> > 10
> >
> >
> >  2  +:&+&+: 3
> > |domain error
> > |   2    +:&+&+:3
> >
> >
> > The 3rd verb (leftmost) is called dyadically (with 0 element? like /?)
> > even though it sees only a monadic expression.
> > ----------------------------------------------------------------------
> > 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
>
----------------------------------------------------------------------
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