At 02:53  -0700 2007/09/23, William James wrote:
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.


Interesting - what did your FreeBasic version look like?

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

Reply via email to