And this is what I came up with. Adverbs every and each are in the z locale.
--Kip
NB. Notice spelling
factors =: [: */every [: { [: (^ [: i. >:)each/ __ q: ]
every
&>
each
&.>
factors 60
1 5
3 15
2 10
6 30
4 20
12 60
Sent from my iPad
On Feb 16, 2013, at 10:16 PM, km <[email protected]> wrote:
> Linda, here is a suggestion:
>
> factrs=: */&>@{@((^ i.@>:)&.>/)@q:~&__
> factrs 60
> 1 5
> 3 15
>
> 2 10
> 6 30
>
> 4 20
> 12 60
>
> factrs1=: */&>@:{@:((^ i.@:>:)&.>/)@:q:~&__
> factrs1 60
> 1 5
> 3 15
>
> 2 10
> 6 30
>
> 4 20
> 12 60
>
> Now you can worry less about ranks.
>
> Kip
>
> Sent from my iPad
>
>
> On Feb 16, 2013, at 9:13 PM, "Linda Alvord" <[email protected]> wrote:
>
>> I am trying to write factrs in simple J. I hit two snags:
>>
>> factrs=: */&>@{@((^ i.@>:)&.>/)@q:~&__
>> 5!:6 <'factrs'
>> ((((((*/)&>)@{)@(((^ (i.@>:))&.>)/))@q:)~)&__
>> factrs 500
>> 1 5 25 125
>> 2 10 50 250
>> 4 20 100 500
>>
>> f=:((((((*/)&>)@{)@(((^ (i.@>:))&.>)/))@q:)~)&__
>> g=:(((^ (i.@>:))&.>)/)
>> g
>> (^ i.@>:)&.>/
>> g 500
>> 500
>>
>> f=:((((((*/)&>)@{)@g)@q:)~)&__
>> h=:(((*/)&>)@{)
>> h
>> */&>@{
>> h 500
>> 500
>>
>> f=:(((h@g)@q:)~)&__
>> f
>> h@g@q:~&__
>>
>> gg=: 13 :'(<( ^ [: i. >:)>)/ y'
>> hh=: 13 :'*/"1>"0{y'
>>
>> ff=:(((hh@g)@q:)~)&__
>> ff 500
>> 1 5 25 125
>> 2 10 50 250
>> 4 20 100 500
>>
>> ff=:(((hh@gg)@q:)~)&__
>> ff 500
>> |length error: gg
>> | ff 500
>> |[-24] c:\users\owner\j701-user\temp\52.ijs
>>
>> I can't understand gg well enough to adjust the rank.
>>
>> What does &__ mean?
>>
>> Linda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm