Copyright 2012, BEST, LLC. All rights reserved.

This patch and the code contained within is licensed 
under the GNU General Public License version 3 
as published by the Free Software Foundation.

diff --git a/ja.h b/ja.h
index 7fa10af..406d7f8 100644
--- a/ja.h
+++ b/ja.h
@@ -368,7 +368,8 @@
 #define fsmvfya(x)                  jtfsmvfya(jt,(x))
 #define ftymes(x,y)                 jtftymes(jt,(x),(y))
 #define fullname(x)                 jtfullname(jt,(x))
-#define fx(x)                       jtfx(jt,(x)) 
+#define fx(x)                       jtfx(jt,(x))
+#define fxx(x)                      jtfxx(jt,(x))
 #define fxchar(x)                   jtfxchar(jt,(x))
 #define fxeach(x)                   jtfxeach(jt,(x))
 #define fxeachv(x,y)                jtfxeachv(jt,(x),(y))
diff --git a/je.h b/je.h
index 405143e..b1f8e9e 100644
--- a/je.h
+++ b/je.h
@@ -13,6 +13,7 @@ extern F1(jtaro);
 extern F1(jtarx);
 extern F1(jtassertq);
 extern F1(jtasserts);
+extern F1(jtatomdf1);
 extern F1(jtbase1);
 extern F1(jtbdot);
 extern F1(jtbehead);
@@ -354,6 +355,7 @@ extern F2(jtapip);
 extern F2(jtapipx);
 extern F2(jtapplystr);
 extern F2(jtatco);
+extern F2(jtatomdf2);
 extern F2(jtatop);
 extern F2(jtbase2);
 extern F2(jtbinrep2);
diff --git a/jtype.h b/jtype.h
index f6993c5..de0b9b7 100644
--- a/jtype.h
+++ b/jtype.h
@@ -336,7 +336,7 @@ typedef struct {AF f1,f2;A f,g,h;I flag,mr,lr,rr,fdep;C id;} V;
 #define VTRY1           (I)4194304      /* monad contains try.             */
 #define VTRY2           (I)8388608      /* dyad  contains try.             */
 #define VDDOP           (I)16777216     /* derived from a derived operator */
-
+#define VDVERB			(I)33554432     /* derived from a verb             */
 
 typedef struct {DX re;DX im;} ZX;
 
diff --git a/px.c b/px.c
index edc1b13..f970b86 100644
--- a/px.c
+++ b/px.c
@@ -72,3 +72,33 @@ F2(jtapplystr){PROLOG;A fs,z;I d;
  FDEPINC(d); z=CALL1(VAV(fs)->f1,w,fs); FDEPDEC(d);
  EPILOG(z); 
 }    /* execute string a on argument w */
+
+DF1(jtatomapply1){DECLFGH;
+ R CALL1(h1,w,hs);
+}
+
+DF2(jtatomapply2){DECLFGH;
+ R CALL2(h2,a,w,hs);
+}
+
+F1(jtatomdf1){A z;
+ RZ(w);
+ if(AT(w)&NOUN) RZ(z=fxx(w))
+ else z=w;
+ ASSERT(AT(z)+VERB+ADV+CONJ,EVDOMAIN);
+ R fdef(CIDA,VERB,jtatomapply1,jtatomapply2,w,0L,z,VDVERB,RMAX,RMAX,RMAX);
+}
+
+F2(jtatomdf2){A z;
+ RZ(a&&w);
+ if(AT(w)&NOUN) RZ(z=fxx(w))
+ else z=w;
+ ASSERT(AT(z)+VERB+ADV+CONJ,EVDOMAIN);
+ RZ(a=vi(a));
+ switch(*AV(a)){
+  case 1: R fdef(CIDA,ADV ,jtatomapply1,0L,a,w,z, 0L, 0L, 0L, 0L);
+  case 2: R fdef(CIDA,CONJ,0L,jtatomapply2,a,w,z, 0L, 0L, 0L, 0L);
+  case 3: R fdef(CIDA,VERB,jtatomapply1,jtatomapply2,a,w,z,VDVERB,RMAX,RMAX,RMAX);
+  default: ASSERT(0,EVDOMAIN);
+ }
+}
diff --git a/r.c b/r.c
index 6f873a0..b309d41 100644
--- a/r.c
+++ b/r.c
@@ -24,9 +24,13 @@ static F1(jtdrr){PROLOG;A df,dg,fs,gs,hs,*x,z;B b,ex,xop;C c,id;I fl,*hv,m;V*v;
  if(ex)RZ(dg=unparsem(zero,w));
  m+=!b&&!xop||hs&&xop;
  GA(z,BOX,m,1,0); x=AAV(z);
- RZ(x[0]=df);
- RZ(x[1]=b||c||xop?dg:fl&VDDOP?(hv=AV(hs),link(sc(hv[0]),link(spellout(id),sc(hv[1])))):spellout(id));
- if(2<m)RZ(x[2]=c||xop?drr(hs):dg);
+ if(id==CIDA){
+  RZ(x[0]=gs?df:spellout(id));
+  RZ(x[1]=gs?spellout(id):df);
+  if(2<m){RZ(x[2]=dg);}
+ }else{RZ(x[0]=df);
+  RZ(x[1]=b||c||xop?dg:fl&VDDOP?(hv=AV(hs),link(sc(hv[0]),link(spellout(id),sc(hv[1])))):spellout(id));
+  if(2<m)RZ(x[2]=c||xop?drr(hs):dg);}
  EPILOG(z);
 }
 
@@ -100,7 +104,7 @@ F1(jtfx){A f,fs,g,h,p,q,*wv,y,*yv;C id;I m,n=0,wd,yd;
    if(id)fs=ds(id);
    ASSERT(fs&&RHS&AT(fs),EVDOMAIN);
    if(!n)R fs;
-   ASSERT(1==n&&ADV&AT(fs)||2==n&&CONJ&AT(fs),EVLENGTH);
+   ASSERT(1==n&&ADV&AT(fs)||2==n&&CONJ&AT(fs)||id==CIDA,EVLENGTH);
    if(0<n){RZ(p=fx(YVR(0))); ASSERT(AT(p)&NOUN+VERB,EVDOMAIN);}
    if(1<n){RZ(q=fx(YVR(1))); ASSERT(AT(q)&NOUN+VERB,EVDOMAIN);}
    R 1==n ? df1(p,fs) : df2(p,q,fs);
diff --git a/rl.c b/rl.c
index 6b85ec8..482c9f5 100644
--- a/rl.c
+++ b/rl.c
@@ -260,10 +260,11 @@ static F2(jtlinsert){A*av,f,g,h,t,t0,t1,t2,*u,y;B b,ft,gt,ht,vb;C c,id;I ad,n;V*
   default:
    t0=CALL2(jt->lcp,ft||NOUN&AT(v->f)&&!(VGERL&v->flag)&&lp(f),f,0);
    t1=lsymb(id,w);
+   if(id==CIDA&&1==n){t2=t1;t1=t0;t0=t2;}
    y=over(t0,laa(t0,t1)?over(chr[' '],t1):t1);
-   if(1==n)R y;
+   if(1==n)R id==CIDA?jtlcpa(jt,1,y):y;
    t2=lcpx(g);
-   R over(y,laa(y,t2)?over(chr[' '],t2):t2);
+   R id==CIDA?jtlcpa(jt,1,over(y,laa(y,t2)?over(chr[' '],t2):t2)):over(y,laa(y,t2)?over(chr[' '],t2):t2);
 }}
 
 static F1(jtlcolon){A*v,x,y;C*s,*s0;I m,n;
diff --git a/t.c b/t.c
index e2f9b07..6506a4f 100644
--- a/t.c
+++ b/t.c
@@ -102,6 +102,7 @@ B jtpinit(J jt){A t;C*s;
  /*  [  */  pdef(CLEFT,   VERB, jtright1,  jtleft2,  RMAX,RMAX,RMAX);
  /*  [: */  pdef(CCAP,    VERB, 0L,        0L,       RMAX,RMAX,RMAX);
  /*  ]  */  pdef(CRIGHT,  VERB, jtright1,  jtright2, RMAX,RMAX,RMAX);
+ /*  ]: */  pdef(CIDA,    VERB, jtatomdf1,jtatomdf2,RMAX,RMAX,RMAX);
  /*  {  */  pdef(CLBRACE, VERB, jtcatalog, jtfrom,   1,   0,   RMAX);
  /*  {. */  pdef(CHEAD,   VERB, jthead,    jttake,   RMAX,1,   RMAX);
  /*  {: */  pdef(CTAIL,   VERB, jttail,    0L,       RMAX,0,   0   );
