[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: PP / PrettyPrint annoyances

Dale Martenson

11/2/2006 4:53:00 PM

Elliot Winkler wrote:

> This behavior is sort of ridiculous in my opinion. I'd rather have
> something
> more like:
>
> [0, 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]

The problem with 'pp' in my opinion is the mysterious 'breakable'. What
you can do is omit the and handle end of line cases in different manner.
Someday I may look at changing 'breakable', but for now this works.

<< START OF CODE

require 'pp'

class PP
def comma
text ','
end

def comma_newline
text ",\n"
end

def seplist_with_limit(list, limit=20, item_sep=nil, line_sep=nil,
iter_method=:each)
item_sep ||= lambda { comma }
line_sep ||= lambda { comma_newline }

count = 0
first = true
list.__send__(iter_method) { |v|
if count % limit == 0
if first
first = false
else
line_sep.call
end
else
item_sep.call
end
yield(v)
count += 1
}
end
end

class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist_with_limit(self, 20) { |v|
q.pp v
}
}
end
end

pp (0..20).to_a

pp (0..40).to_a

>> END OF CODE

--
Posted via http://www.ruby-....

1 Answer

Ric Locke

11/5/2011 10:14:00 PM

0

On Sat, 05 Nov 2011 10:58:56 -0700, Daniel R. Reitman wrote:

> On Sat, 5 Nov 2011 05:19:58 -0600, Ric Locke <ric@riclocke.com> wrote:
>
>>On Fri, 04 Nov 2011 19:46:52 -0700, Daniel R. Reitman wrote:
>
>>> No. The difference between real and nominal, in this context, is
>>> illusory. A fair market value is based on what a willing buyer and
>>> willing seller will agree to buy and sell for. The cumulative
>>> increase in markets defines inflation.
>
>>Migod. No wonder the Occupy people think their proposals perfectly
>>reasonable.
>
> 1. Unnecessary ad hominem attack. You don't even know if I am
> connected with the Occupy protests.

I don't assume that you are. I assume (as displayed here) that you are
working from (at least some of) the same assumptions, and those
assumptions are false to fact.
>
> 2. What do you think I am missing? I am working from the assumption
> that appreciation, to a large extent, averages out over the breadth of
> the economy.

The very definition of "inflation" contradicts that assumption.
Inflation (or deflation) occurs when the number in the price changes,
but the thing purchased does not. The item purchased has not appreciated
(or depreciated) in value; only its price, denominated in dollars, has
increased (or decreased). That's what the word /means/.

When I first started driving, a gallon of 93 octane gasoline (then
called "regular", as opposed to "premium", which was 98 octane or
better) cost around thirty cents. In my area, a gallon of 93 octane
gasoline (now described as "premium") costs just under $4. It's the same
gas (actually, it isn't, because it's 10% ethanol, which has a lower
energy value), used for the same purpose, and has the same value to me,
i.e., it will run my car for X distance. Only the number after the
dollar sign has changed in any substantial way. That's inflation.

Treating inflation as appreciation in value is only a way to confuse the
issue, useful largely to people who see the corresponding salaries and
wages being pushed into plutocrat ranges with corresponding tax
increases, and loving the additional Government revenue. That's how the
Carter Administration used it until the outcry became too great,
whereupon they fixed it at the already-ridiculous level by "indexing"
the tax brackets.

Regards,
Ric