Pascal

>The difficulty is your examples are contradictory. The number 2 is different 
>from the letter 2.

>Perhaps a gold standard of the test case is needed eg
    d2=: <2
or
    d2=: <,2
or
    d2=: <,'2'
or it might be a set...

greg
~krsnadas.org

--

from: 'Pascal Jasmin' via Programming <[email protected]>
to: "[email protected]" <[email protected]>
date: 18 May 2014 06:56
subject: Re: [Jprogramming] ^: and boxes

That is a cool way of getting doubles:

   ([: >: (<2) = 1 |. ]) ;/ 1 2 3 2 2 4 2 1
2 1 2 2 1 2 1 1

>I thank you for the creative approach, while still following all the 
>directions.  I learned something from all of the creative approaches provided. 
> I was most interested in a good way to modify boxed data cells based on the 
>content of other cells.  I understand how people are helpfully trying to solve 
>the problem they want to solve instead of magically reading my intent.  When 
>presenting the problem I prefer that there be a final unboxed presentation for 
>display purposes, and I also prefer the simplest possible data argument, but 
>it makes deciphering my intent more difficult.

>Here is a solution/problem statement that makes the boxed input requirement 
>more than just an inconvenience.  Perhaps if I put white space between the 
>verb and data, its clear that the solution being sought should only modify the 
>left of the white space:

   ((1|.(<2)=]each) +:@]^:[each ])              (<'a') ,~ ;/ 1 2 3 2 2 4 2
+---------------+
¦2¦2¦6¦4¦2¦8¦2¦a¦
+---------------+

>Though that example invites solutions that remove the tail then add it back 
>later :P.  So, perhaps I should provide 2 sample inputs:

   ((1|.(<2)=]each) +:@]^:[each ])      cut '1 2 3 2 2 4 2 a 1'
+-----------------+
¦1¦2¦3¦2¦2¦4¦2¦a¦1¦
+-----------------+

--

From: Joe Bogner <[email protected]>
To: [email protected]
Sent: Sunday, May 18, 2014 8:04:08 AM
Subject: Re: [Jprogramming] ^: and boxes

>I would probably do this. Boxing is based on original requirement of right 
>side being boxed

(> * [: >: (<2) = 1 |. ]) ;/ 1 2 3 2 2 4 2 1
2 2 6 4 2 8 2 1

Works on the negative test too

(> * [: >: (<2) = 1 |. ])  ;/ _1 2 _3 2 2 _4 2 _1
_2 2 _6 4 2 _8 2 _1

>It doesn't use ^: , which was in the subject line and may not be valid if ^: 
>is required

--

from: greg heil <[email protected]>
to: Programming forum <[email protected]>
date: 17 May 2014 08:28
subject: Re: [Jprogramming] ^: and boxes

Linda

>Wow that is super understandable and compact! Of course its domain is limited, 
>Eg it does not like negative numbers:

    d=:  1 2 3 2 2 4 2 1
    dn=: _1 2 _3 2 2 _4 2 _1
    dn=: (]* _1&^ @ (2~:]))  d

    fLA=: ] >. +: * 1 |. 2 = ]
    fLA dn
_1 2 _3 4 2 _4 2 0

>It did take me a _long_ time to penetrate Aai`s sophistry! Finally the key was 
>that /. was really oblique, not key! ...but it does survive this negative 
>number test:

     fA=: [: }. 2&*//.@(2&=,:])
     fA dn
_2 2 _6 4 2 _8 2 _1

>Anyway i think i am awake this am, thanks! i could be fooled though, only 
>dreaming i was awake;)

greg
~krsnadas.org

--

from: Linda Alvord <[email protected]>
to: [email protected]
date: 16 May 2014 21:51
subject: Re: [Jprogramming] ^: and boxes

Maybe you'll like this.


   f=: 13 :'y >.(1 |. 2 = y)*+:y'
   f 1 2 3 2 2 4 2
2 2 6 4 2 8 2

   f
] >. +: * 1 |. 2 = ]

Linda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to