You're trying to make a tacit version of:
{: 3 p: 567
3&p: is the verb you could bind to. And:
{:@(3&:p)
You can always ask for hint/solution by:
13 : '{: 3 p: y'
[: {: 3 p: ]
----- Original Message -----
From: Henry Rich <[email protected]>
To: [email protected]
Cc:
Sent: Monday, February 24, 2014 10:56:10 PM
Subject: Re: [Jprogramming] Finding Largest Prime of Numbers (Tacit)
I can't see any newlines in this post, so it's very hard to see what was
executed. everything runs together.
Henry Rich
On 2/24/2014 10:27 PM, Jon Hough wrote:
> As a beginner in J, I am attempting to get a footing in tacit verbs.Lots of
> things still confuse me, so I want to go through my trial-and-error working,
> and hopefully, if someone has the time, they can explain some things to me.
> First I wanted to find the largest prime divisor of a given number (integer).
> I can output that fairly quickly after rummaging around the J dictionary:
> {: 3 p: 567That works fine.OK, so I want to wrap that into a tacit verb.Here
> was my first attempt:
> bigdiv =. {: 3 p:|syntax error| bigdiv=. {:3 p: I am not sure why this
> fails. Apparently we need a & between the two verbs "{:" and "3 p:". Could
> anyone explain why? I thought for monadic verbs putting & in between them is
> superfluous (incidentally same as putting @).
>
> So my next attempt is to stick a & between the verbs:
> bigdiv =. {: & 3 p: bigdiv 45|domain error: bigdiv| bigdiv 45
>
> I would like to know what the cause of this domain error is.
> Next I put a & between the 3 and p:bigdiv =. {: & 3 & p: bigdiv 45|domain
> error: bigdiv| bigdiv 45 That was a pure guess.
> In exasperation I decided to build my verb by making smaller verbs first.
> divs =. 3 & p: divs 542 3 3 3 This works, but I am unsure why I need the
> &.
> Now I have divs I can make bigdiv:
> bigdiv =. {: & divs bigdiv 543 This works ok. Again why do I need the &?
> Next, I wanted to make bigdiv work on a list, so here is what I did:
> divs =. 3 & p:"0 divs 12 3 4 52 2 33 0 02 2 05 0 0
> bigdiv =. {:"1 & divs bigdiv 12 34 233 17 23
> This seems to work perfectly. Is this the best way to go about doing this in
> J? i.e. If I want to get the largest prime divisor of each element of a list
> then my bigdiv does the job perfectly. Is there a better/faster/more J-esque
> way?
> Finally, why when I try to rebuild my tacit verb does it fail?
> bigdiv =. {:"1 & 3 & p:"0 bigdiv 3 4 23 190|domain error: bigdiv|
> bigdiv 3 4 23 190
> Any and all help appreciated. Thanks in advance.
> Regards,
> ----------------------------------------------------------------------
> 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