That's my 'bivalent': u^:(1:`(]v))
Henry Rich On 7/6/2012 7:13 PM, Don Guinn wrote: > It's always bugged me that nl ignored x and y. So, for the fun of it, I > thought I would try to make nl handle x and y. I pulled a lot of the code > of nl into a tacit expression so x and y would be handled properly. > > nlt=.(4!:1 :: (;:^:(0:=L.)))@(0 1 2 3"_`]@.(*@#)) > > nl_z_=: (nlt : ((4 : 0) nlt)) f. > nms=.y > if. 0 e. #nms do. return. end. > > if. #t=. x -. ' ' do. > 'n s'=. '~*' e. t > t=. t -. '~*' > b=. t&E. &> nms > if. s do. b=. +./"1 b > else. b=. {."1 b end. > nms=. nms #~ n ~: b > end. > ) > > In order to make this work I needed a tacit expression that, given verbs u > and v, would calculate "u v y" if used monadically and "x u v y" if > dyadically. Funny that I couldn't find a simple way to do that in J. The > best I could do was "((u@v) : (u v))". But I couldn't figure out how to > avoid repeating u and v. A while back (when [. and ]. still worked) > something like "u(([.@].) : ([. ].))v" might have worked. As such, u and v > would appear only once. > > Am I missing an easy way to do this? > > On Thu, Jul 5, 2012 at 2:44 PM, ed bierly <ebie...@gmail.com> wrote: > >> thanks >> as you see from the out of order posts i was continuing in the right >> direction >> and as i learn more about j it will probably make sense why that is >> reasonable >> >> On Thu, Jul 5, 2012 at 4:38 PM, ed bierly <ebie...@gmail.com> wrote: >> >>> NB. the implementation of list_z_ seems to invoke this special case for >> x >>> and y >>> >>> (4 !: 1)0 1 2 3 >>> ┌─┬─┬─┐ >>> │x│y│z│ >>> └─┴─┴─┘ >>> names >>> list_z_@nl >>> list_z_ >>> 3 : 0 >>> w=. {.wcsize'' >>> w list y >>> : >>> if. 0=#y do. i.0 0 return. end. >>> if. 2>#$y=. >y do. >>> d=. (' ',LF) {~ LF e. y=. toJ ": y >>> y=. [;._2 y, d #~ d ~: {: y >>> end. >>> y=. y-. ' '{.~ c=. {:$ y=. (": y),.' ' >>> (- 1>. <. x % c) ;\ <"1 y >>> ) >>> >>> >>> On Thu, Jul 5, 2012 at 4:20 PM, ed bierly <ebie...@gmail.com> wrote: >>> >>>> NB. http://www.jsoftware.com/docs/help701/learning/24.htm >>>> >>>> (0 !: 0) < 'economic.ijs' >>>> >>>> names'' >>>> p s >>>> >>>> y >>>> 1932 1934 1957 1969 1972 >>>> >>>> NB. something about x and y only? >>>> >>>> (0 : 0) (1 !: 2) < 'test.ijs' >>>> x=:'ed' >>>> y=:'is' >>>> z=:'confused' >>>> ) >>>> clear'base' >>>> >>>> names'' >>>> (0 !: 0) < 'test.ijs' >>>> names'' >>>> z >>>> >>>> >>> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm