Hi, I'm new to J so my programs might be a bit more complicated than needed, I would be happy if you could tolerate that(and perhaps even give me fixes when needed).
anyway, I have a monad function that checks if a number is a perfect number: (=([:+/((0=((|~)([:>:[:i.-&1)))#([:>:[:i.-&1)))) this monad works for single numbers: (=([:+/((0=((|~)([:>:[:i.-&1)))#([:>:[:i.-&1))))10 0 (=([:+/((0=((|~)([:>:[:i.-&1)))#([:>:[:i.-&1))))12 0 (=([:+/((0=((|~)([:>:[:i.-&1)))#([:>:[:i.-&1))))28 1 but for lists it gives me a length error for some reason: (<([:+/((0=((|~)([:>:[:i.-&1)))#([:>:[:i.-&1))))10,12,28 |length error | (<([:+/((0=((|~)([:>:[:i.-&1)))#([:>:[:i.-&1))))10,12,28 it was my understanding that a monad, when applied to a list, will work for each element separately and then return the list of result, like this: >:i.10 1 2 3 4 5 6 7 8 9 10 I would be very grateful for any help understanding my error, thanks in advance, Uriel. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
