Bjorn Helgason wrote:
> 65 66 67{a.
Thanks. I needed this to convert a simple program that
was posted on the Ruby newsgroup to J.
Here's a cleaned up Ruby version.
def scramble( fname )
_fname = fname + ".scrambled"
data = IO.read( fname )
File.open(_fname, "wb"){|ff|
data.each_byte{|c| ff.write((c | 0x80).chr) }
}
end
Here's my J version.
read =: 1!:1
write =: 1!:2
scramble =: verb define
((128 (23 b.) a. i. read <y) { a. ) write <y,'.scrambled'
)
The J program is about 24 times as fast.
The version I wrote in FreeBasic is 9 times as fast as J.
____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm