From  http://keiapl.org/rhui/remember.htm#fork0

... For years, Ken had struggled to find a way to 
write f+g as in calculus, from the “scalar operators” 
in Operators and Functions [5, section 4], through
 the “til” operator in Practical Uses of a Model of APL [6] 
and Rationalized APL [7, p. 18], and finally forks. 
Forks are defined as follows:
          (f g h) y     ↔        (f y) g (h y)
        x (f g h) y     ↔        (x f y) g (x h y)
Moreover, (f g p q r) ↔ (f g (p q r)) . Thus to write f+g 
as in calculus, one writes f+g in J.  ...

There are ways to create "fork-like" structures in J
using a conjunction.  That is, it is possible to have 
a "simpler" language by removing row 5 of the parse table 
http://www.jsoftware.com/help/dictionary/dicte.htm
but fork is so overwhelmingly important and useful
and it is worth the extra parse rule.

A conjunction that resembles (f &&& g) is the "til" 
operator in Rationalized APL.  See pages 36 and 37 in 
http://www.jsoftware.com/jwiki/Doc/Rationalized_APL
Til can be modeled in J as follows:

til=: 2 : 0
 (v y) u y
:
 (v y) u x
)

For example:
   f=: ('(f '&,)@(,&')')@":
   g=: ('(g '&,)@(,&')')@":
   comma=: , (','&,)

   comma til f til g 5
(f 5),(g 5)

But fork is much better.



----- Original Message -----
From: Tracy Harms <[email protected]>
Date: Wednesday, March 11, 2009 12:05
Subject: [Jprogramming] algebraic formalism excluding trains
To: Programming forum <[email protected]>

> I've been asked whether a particular combinator can be written readily
> in J without relying on verb trains. I've replied in the 
> negative, but
> I'd like to put this before the J community so that my answer 
> may be
> corrected if wrong, or perhaps supplemented.
> 
> Here is the entire conversation between me and Conal Elliott, to date:
> 
> TH:  Rereading John Backus 1977; section 12.9 stands out. 
> Is that
> aspect of this much-lauded paper applied in Haskell?  ... 
> Does Haskell
> follow Backus' advice (esp. 12.9)?
> 
> CE:   I love that backus paper. which advice in 12.9 
> in particular?
> 
> TH:  I hear Backus advise an algebraic form, more 
> restrictive than
> systems of Church or Curry, so that equivalence (e.g.) is more plain.
> 
> CE:  I hear the same. Haskell does not follow that advice.
> 
> TH:  Backus' example is [f , g]o h = [f o h , g o h] which 
> I can write
> in J as (f;g)@h -: (f...@h;g...@h) How would I code it in Haskell?
> 
> CE:  it's called (&&&) in haskell and works for all arrows. on
> functions, it's (f &&& g) x = (f x , g x). See 
> http://bit.ly/11G2IH .
> and yes, (f &&& g) . h == (f . h &&& g . h)
> 
> TH:  Thanks for identifying (&&&). I think there is no 
> equiv. symbol
> in J. Instead, that meaning is implied syntactically; called "fork".
> 
> CE:  if "fork" weren't already in J, could you define it 
> and use it
> conveniently?
> 
> TH:  No. J's verb trains (e.g. fork) allow separation-and-
> rejoining to
> be put in terms of functions, not structures of resulting values.
> 
> 
> My question to the J forum is: Have I erred or overlooked anything?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to