The mistake is that the foldl version only works with a gerund of length 2
(pascal mentioned this in his original post).
Tiny cleanup to rscan:
rscan=: 1 : '((>: - m |&# y) |. m)/y'
i=: 1 : ('m,y'; ':'; 'x,m,y')
('+'i)`('*'i)`('-'i) rscan \ 'abcd'
a
a-b
a*b-c
a+b*c-d
('+'i)`('*'i)`('-'i) rscan \. 'abcd'
a+b*c-d
b*c-d
c-d
d
(If it's not clear, the idea is just to rotate the gerund so that when the
normal '/' is applied, the verbs line up in the order Raul asked for.)
On Wed, Feb 24, 2016 at 4:19 PM, Jose Mario Quintana <
[email protected]> wrote:
> When the gerund is +`%`* and the noun is 1 2 3 4 5 6 7 (I think) the
> values,
>
> 4 + 5 % 6 * 7
> 4.11904762
> 3 * 4 + 5 % 6 * 7
> 12.3571429
>
> should appear in the result. However,
>
> +`%`* fn 1 2 3 4 5 6 7
> 2.12804878 0.161849711 3.06153846 23.4285714 0.119047619 13 7
>
> +`%`* foldl\. 1 2 3 4 5 6 7
> 1.16184971 0.724137931 3.06153846 1.53846154 5.85714286 42 7
>
> +`%`* rscan\. 1 2 3 4 5 6 7
> 1.16184971 0.161849711 12.3571429 4.11904762 0.119047619 42 7
>
> they only appear in Michal's version. Alas, \. does not seem to be
> optimized for this case but I could be wrong.
>
> Did I make any mistakes?
>
>
>
> On Wed, Feb 24, 2016 at 11:14 AM, Michal Wallace <[email protected]
> >
> wrote:
>
> > er... that works better when you define 'i' :)
> >
> > i=: 1 : ('m,y'; ':'; 'x,m,y')
> >
> > On Wed, Feb 24, 2016 at 10:13 AM, Michal Wallace <
> [email protected]
> > >
> > wrote:
> >
> > > rscan:
> > >
> > >
> > > rscan =: 1 : '((>:-(#m)|#y)|.m)/y'
> > > ('!'i)`('?'i)`('|'i) rscan \ 'abcdefghijk'
> > > a
> > > a|b
> > > a?b|c
> > > a!b?c|d
> > > a|b!c?d|e
> > > a?b|c!d?e|f
> > > a!b?c|d!e?f|g
> > > a|b!c?d|e!f?g|h
> > > a?b|c!d?e|f!g?h|i
> > > a!b?c|d!e?f|g!h?i|j
> > > a|b!c?d|e!f?g|h!i?j|k
> > >
> > >
> > > r is for raul or reverse.. take your pick :)
> > >
> > > On Wed, Feb 24, 2016 at 8:57 AM, Alex Shroyer <[email protected]>
> > wrote:
> > >
> > >> 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