[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: format problem

Li Chen

12/11/2006 7:34:00 PM

Hi Paul,

Thank you so much for your time and input.

I just need to print a 2D array to screen in the
following format:

[
[1,2,3,4,5,6,7,8,9,10,11,12],
[13,14,15,16,17,18,19,20,21,22,23,24],
...
[85,86,87,88,89,90,91,92,93,94,95,96]]



After I create a 2D array of 8 row x12 column 2D from
a 1D array I want to print this format directly to the
screen without writing further code lines. If the
column number is less than 10 I can print the
data(using pp) in the format above but if column
number is 12 I can't. To solve this the only thing I
can do is to write another loop(see below) to go
through to the same 2D again.

_2D_array.each{|i| puts i}

Li






____________________________________________________________________________________
Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now.

10 Answers

Paul Lutus

12/11/2006 7:45:00 PM

0

chen li wrote:

> Hi Paul,
>
> Thank you so much for your time and input.
>
> I just need to print a 2D array to screen in the
> following format:
>
> [
> [1,2,3,4,5,6,7,8,9,10,11,12],
> [13,14,15,16,17,18,19,20,21,22,23,24],
> ..
> [85,86,87,88,89,90,91,92,93,94,95,96]]
>
>
>
> After I create a 2D array of 8 row x12 column 2D from
> a 1D array I want to print this format directly to the
> screen without writing further code lines. If the
> column number is less than 10 I can print the
> data(using pp) in the format above but if column
> number is 12 I can't. To solve this the only thing I
> can do is to write another loop(see below) to go
> through to the same 2D again.
>
> _2D_array.each{|i| puts i}

Problem: The library 'pp' cannot produce the result you want.

Solution: don't use 'pp'. Instead, write an additional line of code.

--
Paul Lutus
http://www.ara...

dblack

12/11/2006 9:49:00 PM

0

Paul Lutus

12/11/2006 11:22:00 PM

0

dblack@wobblini.net wrote:

/ ...

>> Problem: The library 'pp' cannot produce the result you want.
>>
>> Solution: don't use 'pp'. Instead, write an additional line of code.
>
> Yes it can. See Eric Hodel's reply and my replies, and see pp.rb.

You reply says that, with sufficient time and patience, you can make a
library produce a result that can also be produced by an additional line of
code. Of course I agree, completely and without reservation.

--
Paul Lutus
http://www.ara...

Michael Black

2/5/2012 10:31:00 PM

0

Ubiquitous

2/6/2012 9:48:00 AM

0

et472@ncf.ca wrote:
>On Sun, 5 Feb 2012, Ubiquitous wrote:
>> ijball-NO_SPAM@mac.invalid wrote:
>>> Ubiquitous <weberm@polaris.net> wrote:

>>>> I watched:
>>>>
>>>> THAT GIRL:
>>>> "Absence Makes the Heart Grow Nervous". Marlo and her loser boyfriend go
>>>> siteseeing in NYC. The WTC is most conspiculously absent.
>>>
>>> Worst. Show. Ever.
>>
>> Ever watch Family Affair?
>
>I watched it all the time, probably more than "That Girl".

OMG, how did you manage to not get diabetes?

>30 years ago, I even knew someone who went to school with "Buffy", who of
>course killed herself sometime in the later seventies.

Isn't that an urban legend?

--
"If Barack Obama isn't careful, he will become the Jimmy Carter of the
21st century."

Jim G.

2/8/2012 5:21:00 PM

0

Ian J. Ball sent the following on Fri, 03 Feb 2012 09:51:07 -0800:
> The Secret Circle - I didn't like this episode either. The good? They're
> making Cassie eviler as they go along.

Cassie is getting more evil? How do you figure?

--
Jim G. | Waukesha, WI
NoCLoDS Founding Member (No Cop, Lawyer or Doctor Shows)

~consul

2/8/2012 7:34:00 PM

0

'tis on this 2/8/2012 9:20 AM, wrote Jim G. thus to say:
> Ian J. Ball sent the following on Fri, 03 Feb 2012 09:51:07 -0800:
>> The Secret Circle - I didn't like this episode either. The good? They're
>> making Cassie eviler as they go along.
> Cassie is getting more evil? How do you figure?

She's not getting more evil, but she is getting very aggressive. In her attitudes to the others and what is right. She is the newcomer, both to the town and to magic, and she is willfully ignoring their suggestions. It can be that she is getting more assertive, but she's being nasty assertive.
--
"... respect, all good works are not done by only good folk. For here, at the end of all things, we shall do what needs to be done."
--till next time, consul -x- <<poetry.dolphins-cove.com>>

Jim G.

2/8/2012 10:09:00 PM

0

~consul sent the following on Wed, 08 Feb 2012 11:34:08 -0800:
> 'tis on this 2/8/2012 9:20 AM, wrote Jim G. thus to say:
> > Ian J. Ball sent the following on Fri, 03 Feb 2012 09:51:07 -0800:
> >> The Secret Circle - I didn't like this episode either. The good? They're
> >> making Cassie eviler as they go along.
> > Cassie is getting more evil? How do you figure?
>
> She's not getting more evil, but she is getting very aggressive.

I'll agree with that. And in fairness to her, it's often because she has
info that others don't have, and sometimes the others don't even care to
find out the facts.

> In her attitudes to the others and what is right. She is the newcomer, both to the town and to magic, and she is willfully ignoring their suggestions. It can be that she is getting more assertive, but she's being nasty assertive.

I think that she's realizing that they don't all share the same goals,
and some of them hardly share *any* in common. She seems to have gotten
more assertive and less patient after hearing that family history bit,
which only served to make her that much more determined to get to the
bottom of things.

--
Jim G. | Waukesha, WI
NoCLoDS Founding Member (No Cop, Lawyer or Doctor Shows)

Ian J. Ball

2/9/2012 1:18:00 PM

0

In article <i714j7trremujd43oap79oe8j1m1j54clk@4ax.com>,
Jim G. <jimgysin@geemail.com> wrote:

> Ian J. Ball sent the following on Fri, 03 Feb 2012 09:51:07 -0800:
> > The Secret Circle - I didn't like this episode either. The good? They're
> > making Cassie eviler as they go along.
>
> Cassie is getting more evil? How do you figure?

She's going around 'mind choking' her friends, and nearly torching
civilians.

Oh yeah, she's getting way evilier!!

--
"We're gonna need a lot of therapy." - the character Rachel in "Bunnyman"
(named 1 of the 5 Worst Horror Films of 2011 by 28DaysLaterAnalysis.com!!)

Jim G.

2/10/2012 12:51:00 AM

0

Ian J. Ball sent the following on Thu, 09 Feb 2012 05:18:13 -0800:
> In article <i714j7trremujd43oap79oe8j1m1j54clk@4ax.com>,
> Jim G. <jimgysin@geemail.com> wrote:
>
> > Ian J. Ball sent the following on Fri, 03 Feb 2012 09:51:07 -0800:
> > > The Secret Circle - I didn't like this episode either. The good? They're
> > > making Cassie eviler as they go along.
> >
> > Cassie is getting more evil? How do you figure?
>
> She's going around 'mind choking' her friends, and nearly torching
> civilians.

She is? I remember her choking Adam by accident and Nick's bro (blanking
on his name) in a dream, but I don't remember her making a career out of
it, or anything. Who all has she done it to?

> Oh yeah, she's getting way evilier!!

Don't be a hater. :)

--
Jim G. | Waukesha, WI
NoCLoDS Founding Member (No Cop, Lawyer or Doctor Shows)