----- Original Message ----- 
From: "Don Watson" <[email protected]>
To: "General forum" <[email protected]>
Sent: Sunday, March 15, 2009 8:26 PM
Subject: Re: [Jgeneral] Teaching


> If we use F to represent +/  , G to represent  # and H1 and H2 to 
> represent
> %  . F and G are monadic as F(x) and G(x) and H is normally dyadic as H
> (x,y). In tacit programming we are replacing    H1  [ F(x), G(x) ]   by  [
> H2 (F, G) ] (x)   In which case H1 and H2 are not the same kind of
> mathematical function - are they?
>
> Don

It would be easier to understand what you are wanting to know if you used 
standard mathematical notation in one expression and J in the other.  I know 
you are wanting to find some way of maintaining consistency but  Ken and 
Roger and many others who have pondered the problem have found the 
simplicity of the parsing rules of J too valuable to compromise.  Perhaps 
the way of tackling this problem should be to show to those writing 
mathematical expressions that they can rewrite many of them in a way 
consistent with J's parsing rules without any loss of clarity.  Indeed often 
it clarifies features since commonly you use the negative number instead of 
subtraction, and many expressions simply become sums.   I have just looked 
at a simple example -
deriving the value of the integral of  (sin x)^5 as a series in (cos x) and 
the whole argument transfers very readily.  It would be great if someone 
wrote some simple introductions to algebra, and to calculus where the J 
syntax is used for derivations as well as calculation.

In your post

F(x) = sum (x)
G(x) = count (x)
H1(x,y) = x/y


In J       H1(F(x),G(x))  just becomes  (F H1 G)
            or  writing it out explicitly  (F x)H1 G x

If your  H1[F(x),G(x)]  is mean to represent an expression in J I do not 
know whether you mean  H1(F(x),G(x)) where H1 is a monadic fucntion with 
argument  (F,G)x   or using H1 dyadically  (F H1 G) x

If one tries to interpret the [ and ] as in J then perhaps you might be 
thinking of   (H1 [ F,G ]) x

However that would require that F and G would be dyadic functions.  The 
expression would parse as

     (H1 ([ F (, G ]))) x

Noting this is a hook in J it can be expressed in conventional terms as
    H1( x , F(x , (G (ravel (x), x) )))

In several posts you have wanted to include 'explicit' expressions in tacit 
ones. There are good reasons for not doing so. While some members of the 
forum try to use tacit for everything, or nearly everything, others find 
that writing explicit functions is the quickest way to complete tasks they 
want.  It can of course be very useful to include powerful tacit functions 
in explicit code.

I would sugget you teach the use of J sentences as an explicit form in 
introductory material.  In that way you can use the powerful structures of J 
and very frequently give a very clear left to right description of the 
algorithm you are using.

sd_of_x  =: sqrt  sum square deviations x

As Brian suggested you can then use the explicit to tacit converter if you 
wish.  the following carries this through

   sd =: 13 : 'sqrt sum square deviations y'
  5!:5  <'sd'
[: sqrt [: sum [: square deviations
   To make this operational you need
sqrt =: %:
sum =: +/
square =: *:
deviations =:  - mean
mean =: sum % #

To apply to general arrays you might modify deviations to
deviations =: - "_ _1 mean

If you enter   load 'primitives'  sqrt and square are defined with 
dictionary names for all the primitives.  I am afraid that goes in an 
alternative direction to your aim of simple one character symbols, but for 
some of your users it may work well.

Fraser

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

Reply via email to