Sorry, it should be
   (t,'x') write <'\junk\foox'
instead of
   (t,x) write <'\junk\foox'




----- Original Message -----
From: Roger Hui <[EMAIL PROTECTED]>
Date: Monday, September 24, 2007 17:35
Subject: Re: [Jprogramming] ASCII bytes to string
To: Programming forum <[email protected]>

> Doing things 4 bytes at a time. Leaner and somewhat faster.
> The improvement is greatest if the file size is a multiple of 4.
> 
> read =: 1!:1
> write =: 1!:2
> 
> scramble =: verb define
>  ((128 (23 b.) a. i. read <y) { a. ) write <y,'.scrambled'
> )
> 
> mask=: {. _2 (3!:4) 4$128{a.
> 
> scramble1=: 3 : 0
>  if. 4|#t=. read <y do.
>   ((#t) {. mask&(23 b.)&.(_2&(3!:4)) t,(4|-#t)$'a') write 
> <y,'.scrambled' else.
>   (        mask&(23 
> b.)&.(_2&(3!:4)) t            ) write <y,'.scrambled'
>  end.
> )
> 
>    t=: read <'\j601\j.dll'
>    #t
> 1314816
> 
>    t write <'\junk\foo'
>    (t,x) write <'\junk\foox'
> 
>    ts=: 6!:2 , 7!:[EMAIL PROTECTED]
> 
>    ts 'scramble ''\junk\foo'''
> 0.0657209 2.0975e7
>    ts 'scramble1 ''\junk\foo'''
> 0.0439592 6.2953e6
>    
>    ts 'scramble ''\junk\foox'''
> 0.0669867 2.09751e7
>    ts 'scramble1 ''\junk\foox'''
> 0.0500449 8.39341e6


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

Reply via email to