bread=:13 : 'frbin read y' bwrite=:13 : '(tobin x) write y' fail because you are not boxing the filename.
Henry Rich On 12/24/2010 7:45 AM, Steven Taylor wrote: > Hi, > > this is the answer I found for a one liner for the question I posed > earlier. This post is an experiment in making J a little more accessible to > newcomers. My ability to debug J expressions has grown slowly over time... > so if I can make that journey a little bit easier for someone, then the > post was worth it. There's nothing particularly new here -- almost > everything is borrowed. > > tobin=:3!:1 > frbin=:3!:2 > read=:(1!:1) > write=:(1!:2) > NB. version 1 > [bread=:13 : 'frbin read y' > [bwrite=:13 : '(tobin x) write y' > > This bwrite fails.. but why because posting the variable in manually works > e.g. (tobin A) write<'c:\temp\A.dat' > This lead me to these expressions > > NB. version 2 > > [bwrite=: 13 : 'a (1!:2)<y [a=.3!:1 x' > NB. [ 'explicit' trick -- found at > http://www.jsoftware.com/help/jforc/explicit-to-tacit_converter.htm > NB. 5!:5<'bwrite' > NB. gives us the tacit form > NB. ([: 3!:1 [) 1!:2 [:< ] > > [bread=: 13 : '3!:2 (1!:1)<y' > NB. 5!:5<'bread' > NB. gives us the tacit form > NB. bread=:[: 3!:2 [: 1!:1< > > NB. TEST > 0 : 0 > A=:i. 3 3 > A bwrite 'c:\temp\A.dat' > [B=:bread 'c:\temp\A.dat' > ) > -Steven > > On 23 December 2010 21:17, Steven Taylor<[email protected]> wrote: > >> just incase anyone else was puzzled like I was... >> >> tobin=:3!:1 NB. to binary >> frombin=:3!:2 NB. convert back from binary >> read=:(1!:1) NB. read file >> write=:(1!:2) NB. write file >> >> A=:i. 50 5 >> >> (tobin A) (1!:2)<'c:\temp\A.dat' >> frombin (1!:1)<'c:\temp\A.dat' >> >> (tobin A) write<'c:\temp\A.dat' >> frombin read<'c:\temp\A.dat' >> >> On 23 December 2010 19:55, Steven Taylor<[email protected]> wrote: >> >>> For a long time I didn't go past vocabulary. Just starting to dig into the >>> script libraries now. Thanks for the sanity check. >>> >>> Looks like I need: >>> >>> [x] 3!:1 y >>> and, >>> 3!:2 y >>> >>> -Steven >>> >> >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
