From: A Bull in the China Shop of Life Date: 2001-07-20T01:25:29+09:00 Subject: [ruby-talk:18128] Debugging minimalism for newbies (Re: Re: An exercise in minimalism) At 12:19 AM 7/20/01 +0900, David Alan Black spewed forth: >Hi -- > >On Thu, 19 Jul 2001, Chris Moline wrote: > > > Here's a first attempt. It weighs in at 66 bytes. > > > > (n=$*[0].to_i).times{|i|s=((n-1)/2-i).abs > > puts " "*s+"#"*(n-2*s)} > ^ > >You can take out that space, in which case I declare a tie :-) >Here's my 65-byte version: > >n=$*[0].to_f/2 >(0-n..n).each{|x|puts" "*x.abs+"#"*(2*(n-x.abs))} > > >But I have to thank you for $* -- I'd been using ARGV. > >My solution is pretty close to a transliteration of my >Perl solution, which was: > >$n=.5*pop;print$"x abs,"#"x(2*($n-abs)),$/for(-$n..$n) > > >David I think it can be a really useful exercise in learning a language to study code like this - one question though. Is there any way to step through this one substatement at a time? When run through the Ruby debugger the debugger wants to treat this as like 2 logical lines which doesn't help :) Turning trace mode on produced WAY too much information - I was hoping maybe to see values propagate up to the surface and be output but maybe I'm mis-reading the purpose of trace mode. Any suggestions anyone? Thanks, -Chris