>From: Jose Mario Quintana <[EMAIL PROTECTED]>
> That is right! Instead of the current behavior, (using symbolic verbs to
> illustrate), 
> 
> (u v)Y
> (Y u (v Y))
> X(u v)Y
> (X u (v Y))
> 
> (u v vv)Y
> ((u Y) v (vv Y))
> X(u v vv)Y
> ((X u Y) v (X vv Y))
> 
> One could have had, , as you suggested,
> 
> (u v)Y
> (u (v Y))
> X(u v)Y NB. No change 
> (X u (v Y))
> 
> and I would even consider,
> 
> (u v vv)Y
> (u (v (vv Y)))
> X(u v vv)Y NB. (No structural change, but without any assumed
> order of execution regarding u vs. vv!)
> ((X u Y) v (X vv Y)) 
>
 
 
I built the verb AltParse  and the adverb Code to have an inefficient but 
functional playground for testing an alternative J by means of modifying the 
parsing rules; a sample session follws.
 
   NB. Symbolic verbs and nouns...
   
   f=: ('('"_ , 'f '"_ , ] , ')'"_) :('('"_ , [ , ' f '"_ , ] , ')'"_)
   g=: ('('"_ , 'g '"_ , ] , ')'"_) :('('"_ , [ , ' g '"_ , ] , ')'"_)
   h=: ('('"_ , 'h '"_ , ] , ')'"_) :('('"_ , [ , ' h '"_ , ] , ')'"_)
   X=. 'X' [ Y=. 'Y'
   
   f X
(f X)
   X g Y
(X g Y)
    
   NB. Standard trains...
   
   (f g) Y
(Y f (g Y))
   X (f g) Y
(X f (g Y))
   
   (f g h) Y
((f Y) g (h Y))
   X (f g h) Y
((X f Y) g (X h Y))
   
   
   
   AltParse Code
 
NB. Alternative trains...
 
(f g) Y
X (f g) Y
 
(f g h) Y
X (f g h) Y
 
NB. Sample coding...
 
(>: >: >: >:) 0
((>: >:) (>: >:)) 0
 
SumOfSquares=: +/ *:
 
SumOfSquares i. 4
 
NB.  The standard train rules still apply for the internal behavior of f g h...
 
f Y
X f Y
 
NB.  However, we could redefine them according to the alternative rules.  For 
example,
 
f
 
NB. can be redefined as,
 
f=: (('('"_ , 'f '"_ , ] , ')'"_)~ :('('"_ , [ , ' f '"_ , ] , ')'"_))
 
f X
 
X f Y
 
..
 
)
( f g ) Y
   '(f (g Y))'
(f (g Y))
X ( f g ) Y
   '(X f (g Y))'
(X f (g Y))
( f g h ) Y
   '(f (g (h Y)))'
(f (g (h Y)))
X ( f g h ) Y
   '((X f Y) g (X h Y))'
((X f Y) g (X h Y))
( >: >: >: >: ) 0
   4
4
( ( >: >: ) ( >: >: ) ) 0
   4
4
SumOfSquares =: + / *:
   +/@:*: :(+/ *:)
+/@:*: :(+/ *:)
SumOfSquares i. 4
   14
14
f Y
   '(f Y)'
(f Y)
X f Y
   '(X f Y)'
(X f Y)
f
   f
('('"_ , 'f '"_ , ] , ')'"_) :('('"_ , [ , ' f '"_ , ] , ')'"_)
f =: ( ( '(' " _ , 'f ' " _ , ] , ')' " _ ) ~ : ( '(' " _ , [ , ' f ' " _ , ] , 
')' " _ ) )
   '('"_@:,@:('f '"_@:,@:(]@:,@:(')'"_) :(] , ')'"_)) :('f '"_ , ]@:,@:(')'"_) 
:(] , ')'"_))) :('('"_ , 'f '"_@:,@:(]@:,@:(')'"_) :(] , ')'"_)) :('f '"_ , 
]@:,@:(')'"_) :(] , ')'"_)))~ :('('"_ , [@:,@:(' f '"_@:,@:(]@:,@:(')'"_) :(] , 
')'"_)) :(' f '"_ , ]@:,@:(')'"_) :(] , ')'"_))) :([ , ' f 
'"_@:,@:(]@:,@:(')'"_) :(] , ')'"_)) :(' f '"_ , ]@:,@:(')'"_) :(] , ')'"_))))
'('"_@:,@:('f '"_@:,@:(]@:,@:(')'"_) :(] , ')'"_)) :('f '"_ , ]@:,@:(')'"_) :(] 
, ')'"_))) :('('"_ , 'f '"_@:,@:(]@:,@:(')'"_) :(] , ')'"_)) :('f '"_ , 
]@:,@:(')'"_) :(] , ')'"_)))~ :('('"_ , [@:,@:(' f '"_@:,@:(]@:,@:(')'"_) :(] , 
')'"_)) :(' f '"_ , ]@:,...
f X
   '(f X)'
(f X)
X f Y
   '(X f Y)'
(X f Y)
..
    ..
 ..
 
 
After playing around with this alter J, the suggestion for this alternative 
monadic hook and fork does not seem to be a good idea anymore.  

AltParse works by intercepting and modifying (when is necessary) J sentences as 
they are being interpreted by Roger Stokes’ EVM parser cited in Learning J.  In 
the sample session (u v) is replaced by (u@:v) : (u v) and (u v w) by (u@:v@:w) 
: (u v w).  (It is a tedious process to set a modification up for an alter J 
but I could provide directly the code if anyone is interested.)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to