I should have been more explicit rather than assuming the reader 
would realize that entering a verb (Pi in this case) displays its 
definition. Further, in the spirit of the Subject line, I should 
enhance my Pi verb a bit by changing it to:

    Pi=: (3: + j.~) ": [: (<....@o. % ]) 10"_ ^ x:
    NB. so that things were formatted in a prettier manner
    Pi 10 20
  3.1415926535 3.14159265358979323846

actually, for Dieter's original question, I should have stuck to the 
things John Randall supplied (I did mention the J essay in my message 
too) and suggested that Dieter try something like:

    pi =: [: (<....@o. % ]) 10"_ ^ x:
    pi 10
6283185307r2000000000
    pi 10 20
6283185307r2000000000 157079632679489661923r50000000000000000000

because this returns results (to the requested precision) in numeric 
form that can be used in further computations, including formatting, 
e.g.

    0j20 ": pi 10 20
3.14159265350000000000 3.14159265358979323846

notice that pi 10 produces a number that is less "accurate" than the 
floating point representtaion given by o.1 directly.

Dieter, you do have to pay attention to the rules for number 
formation etc., but many times expressions such as mine above include 
the blanks mainly to help your eyes parse the expression - the pi 
verb above works find with no blanks at all. But I would say it is 
harder to read.

    pi=:[:(<....@o.%])10"_^x:
    pi 10 20
6283185307r2000000000 157079632679489661923r50000000000000000000



At 13:39  -0400 2009/08/08, Devon McCormick wrote:
>Dieter -
>
>I think your confusion stems from this:
>
>Joey K Tuttle <[email protected]> (on Fri, Aug 7, 2009 at 1:54 PM)  included part
>of a J session:
>>     Pi 50
>>  3.14159265358979323846264338327950288419716939937510
>>     Pi
>  > (2: + j.~) ": [: (<....@o. % ]) 10"_ ^ x:


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to