Correction: I see five different ways of using a single pair of parenthesis to separate the 3 and the 169.
(I believed there was a fifth way but I needed to eat breakfast before I could think clearly enough to see it.) Can you find them all? Thanks, -- Raul On Thu, Sep 4, 2014 at 5:38 PM, Raul Miller <[email protected]> wrote: > Just so it's clear what has happened here: > > ;:'SumOfFact^:3 169' > +---------+--+-----+ > |SumOfFact|^:|3 169| > +---------+--+-----+ > > In other words, 3 169 is a single word. It's a word that happens to have a > space in it, but that's actually not at all unusual. Here's another example > of a word with a space in it: > > 'this is a test' > > Actually, that particular word has three spaces in it. But that counts, > right? > > Note that some people prefer to call words "tokens" for various reasons. > > Note also that we train our eyes to see these things. To someone who has > never studied computer programming languages, 'this is a test' might look > like four words where two of them contain apostrophes. But someone familiar > with quoting rules can see it as a single "thing" and - if they've played > with implementations of parsers or similar things - they'll have an idea > about why it's worth calling this thing a "word" or a "token". > > Anyways, I have had this happen to me relatively often, so I am familiar > with its symptoms. I'll have a J sentence which uses a number and I will > add another number to it, and I will want it to be a different word, and I > have to remind myself to make it be one. > > Meanwhile some other messages have provided some examples of how to break > 3 169 into two separate words, so I'll skip that part. But I'll note that I > see four different ways of using a single pair of parenthesis to accomplish > this. > > Thanks, > > -- > Raul > > On Thu, Sep 4, 2014 at 2:55 PM, alessandro codenotti <[email protected]> > 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
