This was from a fresh start in Jjhs:

   factorslla =: [: */"1 [: > [: { [: ([: < ( ^ ([: i. >:)))"0/ __ q: ]
   factorslla 3894
 1   59
11  649

 3  177
33 1947


 2  118
22 1298

 6  354
66 3894
   
Linda


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Dan Bron
Sent: Wednesday, February 20, 2013 7:43 AM
To: [email protected]
Subject: Re: [Jprogramming] Recursive programming (and scoping therein)

Looks like the hook caught you.

   factorslla =: [: */"1 [: > [: { [: ([: < ( ^ ([: i. >:)))"0/ __ q: ]
   factorsllb =: [: */"1 [: > [: { [: ([: < [ ^  [: i. >:  )"0/ __ q: ]

   $factorslla 3894
1 1 1 1

   $factorsllb 3894
1 1 1 1

   (factorslla -: factorsllb) 3894
1

-Dan

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Wednesday, February 20, 2013 5:15 AM
To: [email protected]
Subject: Re: [Jprogramming] Recursive programming (and scoping therein)

When can you remove the inner parentheses from the right safely? I would
apply the functions from right to left.

f=: [: */"1 [: > [: { [: ([: < ^ [: i. >:)"0/ __ q: ]
   f 3894
|domain error: f
|       f 3894
   
   factorslla
[: */"1 [: > [: { [: ([: < (^ ([: i. >:)))"0/ __ q: ]
   factorslla
[: */"1 [: > [: { [: ([: < (^ ([: i. >:)))"0/ __ q: ]
   factorslla 3894
 1   59
11  649

 3  177
33 1947


 2  118
22 1298

 6  354
66 3894

Linda
 
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Wedn]esday, February 20, 2013 4:30 AM
To: [email protected]
Subject: Re: [Jprogramming] Recursive programming (and scoping therein)

I never stopped believing it was possible in simple J! Kip once you chopped
it up with "each"  and "every" it came apart. 

   factrs=: */&>@{@((^ i.@>:)&.>/)@q:~&__    factrs 72
1  3  9
2  6 18
4 12 36
8 24 72
   
   ii=:[: < (^ ([: i. >:))
   A=:__ q: ]
   f=:([:ii"0 / A)
   f 72
--------T-----┐
│1 2 4 8│1 3 9│
L-------+------
   g=:  13 :'*/"1>{ f y'
   g 72
1  3  9
2  6 18
4 12 36
8 24 72
   
   factorslla=: 13 :'*/"1>{([:([: < (^ ([: i. >:)))"0 /(__ q: ]))y'
   factorslla 72
1  3  9
2  6 18
4 12 36
8 24 72
  
   factorslla
[: */"1 [: > [: { [: ([: < (^ ([: i. >:)))"0/ __ q: ]
   
Linda

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of km
Sent: Sunday, February 17, 2013 6:50 PM
To: [email protected]
Subject: Re: [Jprogramming] Recursive programming (and scoping therein)

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
----------------------------------------------------------------------
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