I believe this works on gerunds of length >= 2:

foldl2=: 1 : '{.`([: $: _2&}. , m ugly)@.(*@<:@#)'
ugly=: 1 : '({:y) (m {~ (#m) | _3 + #y)`:6 (_2{y)'

I don't know how to write the ugly part tacitly. It doesn't work with suffix 
(\.) either.

     +`* foldl2 >: i.7
209
     +`*`+ foldl2 >: i.5
30
     1 + (2 + (3 * (4 + 5)))
30
     $ +`* foldl2\. >: i.7
7 6 5 4 3 2 1

Any idea why it returns a rank 7 array?

Louis

> On 24 Feb 2016, at 19:26, Alex Shroyer <[email protected]> wrote:
> 
> That's really cool, Pascal.
> 
>> On Wed, Feb 24, 2016 at 12:22 PM, Skip Cave <[email protected]> wrote:
>> 
>> Pascal said:
>> 
>>     foldl =: 1 : 'm/`((|.m)/)'
>>     *`+ foldl\. >: i.7
>> 209 209 207 69 65 13 7
>> 
>> <<<>>>
>> 
>>     %`- foldl\. >: i.7
>> 0.6 1.66667 0.333333 9 _5 _1 7
>> 
>> Nice! I think the foldl definition can be classified "simple" as well!
>> 
>> Skip
>> 
>> 
>> On Wed, Feb 24, 2016 at 11:02 AM, Pascal Jasmin <[email protected]>
>> wrote:
>>> with just 2 gerund items,
>>> 
>>> 
>>> foldl =: 1 : 'm/`((|.m)/)'
>>> 
>>> 
>>> *`+ foldl\. >: i.7
>>> 209 209 207 69 65 13 7
>>> 
>>> 
>>> ----- Original Message -----
>>> From: Alex Shroyer <[email protected]>
>>> To: [email protected]
>>> Sent: Wednesday, February 24, 2016 9:57 AM
>>> Subject: Re: [Jprogramming] Am I understanding m/y ?
>>> 
>>> For Skip's example, a completely literal version:
>>> 
>>> ((*`+)/)`((+`*)/)\. >:i.7
>>> 
>>> On Wed, Feb 24, 2016 at 9:25 AM, Brian Schott <[email protected]>
>>> wrote:
>>> 
>>>> Pascal,
>>>> 
>>>> I think your <: is too limiting. But I love your approach.
>>>> 
>>>> fn =: <@|.@[ (|.each@:|.@:($~ each 1 >.   <:)  4 : 'x/ y' every
>> <\.@]) ]
>>>> fn =: <@|.@[ (|.each@:|.@:($~ each 1 >. i.@#)  4 : 'x/ y' every
>> <\.@]) ]
>>>> 
>>>> On Tue, Feb 23, 2016 at 10:51 PM, Pascal Jasmin <[email protected]
>>> 
>>>> wrote:
>>>> 
>>>>> fn =: <@|.@[ (|.each@:|.@:($~ each 1 >. <:)  4 : 'x/ y' every
>> <\.@]) ]
>>>>> 
>>>>> 
>>>>> %`- fn 1 2 3 4 5 6 7
>>>>> 0.6 1.66667 0.333333 9 _5 _1 7
>>>>> 
>>>>> 
>>>>> *`+ fn 1 2 3 4 5 6 7
>>>>> 209 209 207 69 65 13 7
>>>> ----------------------------------------------------------------------
>>>> 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