[Jprogramming] Applying different verbs to different items.

'Rob Hodgkinson' via Programming programming at jsoftware.com
Fri May 3 07:03:50 UTC 2019


Yes, a little tricky due to gerund binding with oblique.

If you really want a “c” for now (someone else may suggest a tacit way overnight) you can use explicit as here;

   c=: 4 : '(x/."1 &. |:)y’

   g=. *: ` -: `^
   y=. 3 1 0
   ] yy=.3 2$2#yy
3 3
1 1
0 0

   g c y
9 0.5 1

   g c yy
9 9
0.5 0.5
1 1

…/Rob

> On 3 May 2019, at 4:54 pm, Piet de Jong <pietdion at gmail.com> wrote:
> 
> Thanks for looking at this.   The problem (or maybe I misunderstand) with this solution is that there is no real “c” in the sense that 
> 
> g c y 
> 
> is the required answer.    That is 
> 
>  *:`-:`^ (/."1 &. |:)   i. 3 5
> 
> (where c is the stuff in brackets) doesn’t work.   
> 
> 
>> On 3 May 2019, at 3:58 pm, 'robert therriault' via Programming <programming at jsoftware.com> wrote:
>> 
>> Hi Piet,
>> 
>> I am not sure how simple it is, but combining Rob's excellent insight on oblique with Transpose, Under and rank 1 you get this:
>> 
>>   (*:`-:`^ /.)"1 &. |: i. 3 5
>>     0       1      4      9       16
>>   2.5       3    3.5      4      4.5
>> 22026.5 59874.1 162755 442413 1.2026e6
>> 
>> The transpose works in this case because the 3 gerunds are applied to each transposed row and then Under (&.) undoes the transpose to provide the results in a shape of 3 5
>> 
>> Cheers, bob
>> 
>>> On May 2, 2019, at 10:15 PM, Piet de Jong <pietdion at gmail.com> wrote:
>>> 
>>> Thanks!   But it doesn’t appear to generalise to applying successive verbs in the gerund to successive >>items<< in y.  
>>> 
>>> (I checked the dictionary re /. and it  talks of “collections” of y.   Not sure what that means)
>>> 
>>> For example if y is i.3 5 then I’d like the first verb in the gerund to apply to the first item of y, the second verb to the second item, and so on.
>>> 
>>> Is there a simple solution for this?     
>>> 
>>>> On 3 May 2019, at 12:35 pm, 'Rob Hodgkinson' via Programming <programming at jsoftware.com> wrote:
>>>> 
>>>> Hi Piet, not ignorant at all !
>>>> 
>>>> Try using oblique (an obscure feature is that the u in u/. can be a gerund, in which case it is evoked cell wise);
>>>> 
>>>> g=. *: ` -: `^
>>>> y=. 3 1 0
>>>> g /. y
>>>> 9
>>>> 0.5
>>>> 1
>>>> 
>>>> Found in Section 15 of https://www.jsoftware.com/books/pdf/brief.pdf <https://www.jsoftware.com/books/pdf/brief.pdf>.
>>>> 
>>>> HTH, Regards Rob
>>>> 
>>>>> On 3 May 2019, at 10:59 am, pietdion <pietdion at gmail.com> wrote:
>>>>> 
>>>>> Hopefully not an ignorant question.
>>>>> 
>>>>> Am looking for a simple (tacit, non complicated) construction (verb?
>>>>> adverb? conjunction?) “c" that takes a gerund and applies the successive
>>>>> verbs in the gerund to successive items.
>>>>> 
>>>>> A simple example is
>>>>> 
>>>>> g=. *: ` -: `^
>>>>> y=. 3 1 0
>>>>> g  c  y
>>>>> 9  0.5  1
>>>>> 
>>>>> What “c”  achieves this for arbitrary gerunds g's and y’s?
>>>>> 
>>>>> I realise this can be done in a variety of explicit ways and  with the
>>>>> agenda construct.    All I can come up with is intricate constructions.
>>>>> Looking for something simple and direct.   Seems to have a lot of uses.
>>>>> ----------------------------------------------------------------------
>>>>> 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



More information about the Programming mailing list