Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Line Noise (was Punctuation as noise)

Reply
Thread Tools

Line Noise (was Punctuation as noise)

 
 
Jim Weirich
Guest
Posts: n/a
 
      08-21-2003
On Wed, 2003-08-20 at 13:49, Hal E. Fulton wrote:
Hal Fulton wrote:

> I cranked out a quick bit of ugly code (see
> below). Obviously it's crude -- e.g., it doesn't
> take note of strings or comments (and it's not
> clear what it should do if it did).


I did something like this a while back when a Java programmer complained
about all that "line noise" in Ruby. I pointed out that Java used much
more puncuation than the typical Ruby program and wrote the following
program to demonstrate...

#!/usr/bin/env ruby
ARGV.each { |fn|
noise = open(fn) { |file| file.read }.gsub(/[A-Za-z0-9_ \t\n]/m, "")
puts "#{fn} (#{noise.size}): #{noise}"
}

Runnnig this over a set of programs written in different languages
gives...

animal.cc (83):
#<>{)=;};:{);};:){::<<"\";}:{);};:){::<< "\";}(){*[]={,};(=;<;++)[]->();;}
Animal.java (67):
{{();}{(){..("");}}{(){..("");}}([]){[]=[]{(),()};(=;<.;++)[].();}}
animal.pl (41): ;{{};}{"\";};{{};}{"\";};$(->,->){$->();}
animal.py (23): ):""):""[(),()]:.()
animal.rb (10): """"[.,.].

Onestepback.org is down at the moment, but I'll post the code for all
the animal programs there when it comes back online.

--
-- Jim Weirich http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ISO noise vs. long exposure noise Cynicor Digital Photography 5 08-27-2005 06:14 PM
Non-noise words are incorrectly recognised as noise words. Peter Strĝiman ASP .Net 1 08-23-2005 01:26 PM
Noise about noise... Stacey Digital Photography 3 02-18-2005 05:57 AM
Noise Ninja custom noise print- worth the effort for stacked photo?? Jason Sommers Digital Photography 4 01-19-2005 06:54 AM
Canon 1Ds Mark II - Noise? What noise? Brian C. Baird Digital Photography 9 09-21-2004 09:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57