Trace has a problem.  It works fine with an explicit statement.

   require'trace'
   trace 'f=:{: 3 p: 23434'
 --------------- 2 Dyad -------
 3
 p:
 23434
 2 11717
 --------------- 0 Monad ------
 {:
 2 11717
 11717
 --------------- 7 Is ---------
 f
 =:
 11717
 11717
 ==============================
11717
   
This is ok. Now try the tacit expression.

   f 23434
11717
   f
[: {: 3 p: ]
   
   
   trace 'g=:[: {: 3 p: 23434'
 --------------- 2 Dyad -------
 3
 p:
 23434
 2 11717
 --------------- 1 Monad ------
 {:
 2 11717
 11717
 --------------- 0 Monad ------
 [:
 11717
|domain error: executet
|   t_z=.    ([:)(11717)
 

Is trace not appropriate for tacit verbs?

Linda  

-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of David Lambert
Sent: Tuesday, February 25, 2014 1:13 AM
To: programming
Subject: Re: [Jprogramming] Finding Largest Prime of Numbers (Tacit)

j is a multiple instruction single data language and has many many ways 
to pass data, including as far as I can tell all combinations of 
monadic, dyadic verbs considering single verbs, their obverses where 
practical, the trains of even numbers of verbs, and of odd numbers of 
verbs with more than two verbs.  Trains have infinite rank, that's why 
we cannot consider a single verb as a train.  The train/rank question 
often appears first with table.  (Usually) use the train atomically, at 
rank 0 .

   X train"0/ Y

Assigning a list of verbs to a proverbial name is a most surprising 
aspects of j, one which I didn't realize from the documents for a long 
long time.  Where stated "Substituted as if in parentheses." is an 
absolutely huge short sentence.  Parentheses completely change (what I 
thought I had as) the sentence.  If

    {: q: 45
5

    biggest_prime_factor_wrong =: {: q:

    biggest_prime_factor_wrong 45
|domain error: biggest_prime_factor_wrong
|       biggest_prime_factor_wrong 45

biggest_prime_factor_wrong is a hook with hook data passing.  {: doesn't 
have a dyadic definition.  Hence the domain error of
    ({: q:) 45   NB. equivalent to 45 {: q: 45

As far as I can tell, cap in a fork effectively means to use the monadic 
definition of the verb immediately to that cap's right.

    biggest_prime_factor =: [: {: q:

    biggest_prime_factor 45
5

Other choices.   Of those that are correct for a purpose the performance 
can drastically vary.  Use the largest chunks possible to keep j from 
devoting resources to checking data types, frames, and item rank.  
Conjunctions here bind first, and from left to right form verbs:

    {:@q: 45
5
    {:@:q: 45
5
    {:&q: 45
5
    {:&:q: 45
5

I've personally chosen to write verbs tacitly in the interpreter session 
with parentheses, using under, at, atop, compose, or  appose when I can 
so that I can directly create proverbs.   Having little faith in the 
future ordering of prime factors, I'd use bpf =: ([: >./ q:) , 
emphasizing the train with parentheses.

Stick with j though it may take years, and please pounce on my errors,
David Lambert
----------------------------------------------------------------------
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