Just a side note--you used 'f' in two places.

Anyway, the main point is that you only want to add ([: (-~ <./) grp) at the
end to correct for errors in your leading zeros. If you add it in before you
index with f, you are just using the wrong digits.

And just in case your question was about the actual parsing, g in your
second example (digits +  [:(-~<./)grp) will be parsed before f...@g is
computed, so it is like you do all of g and then f. @ won't go inside the
train to combine the verbs. In fact it doesn't even look at the definition
of g, so it can't know it is a fork.

Marshall


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of gary ng
Sent: Monday, August 30, 2010 9:29 PM
To: Programming forum
Subject: Re: [Jprogramming] Splitting an integer into its digits

On Mon, Aug 30, 2010 at 5:50 PM, Marshall Lochbaum
<[email protected]> wrote:
>  I think--although I am unclear on your question exactly--that you are 
> mixing up
>   (+/"1@({&f)@digits + [:(-~<./)grp) i.11 With
>   +/"1@({&f)@(digits + [:(-~<./)grp) i.11
>
I am indeed. thanks.

f=. +/"1@({&f)@digits
g=. +
h =. [:(-~<./)grp

(f g h) i.11

Though the followup question is, why would digits become part of f rather
than the following :

f = .(+/"1@({&f)
g =. digits +  [:(-~<./)grp

(f...@g) i.11

I think I am confused with the '@'  and treat it like  '|' in shell script.
----------------------------------------------------------------------
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