As an  alternative to  the representation foreign  conjunctions,
this method includes arguments.  Ambivalent verbs A, B, C, and D
return characters, and are alike but for the name they insert.
Definitions are at message end.

   (A 'y') , (14#' ') , ('x' C 'y')
( A y )              ( x C y )
   
   (A B)'y'     NB. monadic hook
( y A ( B y ) )

   ([: A B)'y'  NB. capped monadic fork
( A ( B y ) )

   A@:B 'y'     NB. at
( A ( B y ) )

   'x' (A~ B)~ 'y'    NB. dyadic "left hook"
( ( B x ) A y )
   

   NB. Mildly helpful to understand rank.

   B i.2
( B 0 1 )

   B"0 i.2
( B 0 )
( B 1 )

   'abc' A"1 0 i.2
( abc A 0 )
( abc A 1 )

   A@:(B"0) i.3    NB. LOL
(((((((
       
AAAAAAA
       
( B 0 )
( B 1 )
( B 2 )
       
)))))))


   NB. hooks

   0 ((A B) C) 1
( 0 A ( B ( C 1 ) ) )

   0 (A (B C)) 1
( 0 A ( 1 B ( C 1 ) ) )


   NB. definitions
   enclose=: >@:{.@:[ , ] , >@:{:@:[
   f=:1 : 0
'()'enclose' 'enclose(":m),' ',":y
:
'()'enclose' 'enclose(x;&":y)enclose' 'enclose":m
)
   '`A B C D'=:('A'f)`('B'f)`('C'f)`('D'f)  NB. I'll bet there's a
shorthand.
   'balanced?' enclose~ 'left(' ; ')'
left(balanced?)
   0 enclose&.:|:0 enclose >:i.2 3

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

Reply via email to