You need to separate the*^:3* from 169
*^:3 169* is giving 2 arguments to*^:*
You can do it by*^:3 ]169 * (Boss) or by
*(^:3) 169* (Murray) or by *^:3 (169)*
Possibly the sumfact verb could be simplified by use of #:
sumF=: +/@:!@:(10 10 10 #:])
for variable length numbers use (>.+10^.y)#:y
Don Kelly
On 04/09/2014 11:55 AM, alessandro codenotti wrote:
I'm working on PE#74, which asks for the sum of the factorials of the digits in
a number
(i.e. if the number is 169 then it asks for 1!+6!+9!).
I wrote this verb that performs the required operation:
SumOfFact=: 3 : 0
+/!"."0@": y
)
It works perfectly, but now I need to reiterate it to produce a chain like 169 ->
363601 -> 1454 -> 169,so I tried:
SumOfFact^:3 169
But instead of working as I hoped it simply writes "SumOfFact^:3 169" as output.
What am I doing wrong and how am I supposed to repeatedly apply a verb to an
argument?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm