[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

printing an integer with leading zeros

Jim Newton

1/29/2016 2:53:00 PM

In order to use format to print an integer with leading zeros, I have to use something
like the following
(format t "~10,'0D" 12)
which prints
0000000012

However, I don't find that in the spec.
Here is what I found
http://www.lispworks.com/documentation/HyperSpec/Body/...
~mincol,padcharD uses padchar as the pad character instead of space.

It says I can put a patcher between the , and the D.
I interpret this to mean that the syntax should be the following
to define a field of width 10 with a pad character of 0: (format t "~10,0D" 12)

But apparently I have to put a ' before the padchar.

Can someone explain this to me.

Thanks.
6 Answers

James Meyers

1/3/2013 5:20:00 PM

0


"ColdWarDinosaur" <wynnehenry!@yahoo.co.uk> wrote in message
news:kc4bou$bn4$3@dont-email.me...
> Thats why conservatives are so messed up. They live in the past. it
> was Boehner's congress.
>
> On 1/3/2013 11:25 AM, BeamMeUpScotty wrote:
>> On 1/3/2013 10:19 AM, Nickname unavailable wrote:
>>> "CONSERVATIVE " extremism: Good Riddance to Rottenest Congress in
>>> History: the 3 worst congresses on record were "CONSERVATIVE" because
>>> of them, the worst is yet to come
>>
>>
>> *CONSERVATIVE* is by definition "NOT EXTREMISM"
>>
>>
>> Conservatism "if extreme and wild ideas" is NOT being conservative.
>>
>>
>> Conservatism is: NOT changing quickly from the norm in radical ways in
>> any direction.
>>
>>
>>
>> Which mean the "extremists are the radical Progressives".
>>
>>
>> And Obama is a Progressive-Socialist radical and Obama and his ilk are
>> the extremists.
>>
>>
>> Voters Nation wide handed Pelosi her hat and asked her to leave, it's
>> only her corrupt local politics that kept her in office at all, but on
>> the National level they let her know she was a Lying Bitch.
>>
>
>
> --
> ~~
> HW
> __________________
> The GOP Claim TO Be Christian but:
> Are Capitalist Extremists.
> Support Law of the Jungle, Survival of the Richest.
> Are Racists.
> Are Pro-War.
> Are Pro-Torture.
> Are Pro-Execution.
> Are Pro-Money-lender.
> Despise Human Rights.
> Despise The Poor.
> Despise Women.
> Despise the Disabled.
> They appear to be against everything Jesus stood for.
> Who are these people really??
and you are a lying piece of shit. You make a lot of statements now prove
any of them.


Clave

1/3/2013 7:37:00 PM

0


"BeamMeUpScotty" <ThenDestroyEverything@blackhole.nebulax.com> wrote in
message news:50E5B117.3030605@blackhole.nebulax.com...
> On 1/3/2013 10:19 AM, Nickname unavailable wrote:
>> "CONSERVATIVE " extremism: Good Riddance to Rottenest Congress in
>> History: the 3 worst congresses on record were "CONSERVATIVE" because
>> of them, the worst is yet to come
>
>
> *CONSERVATIVE* is by definition "NOT EXTREMISM"
>
>
> Conservatism "if extreme and wild ideas" is NOT being conservative...

http://rationalwiki.org/wiki/No_Tru...

Jim







ColdWarDinosaur

1/3/2013 8:43:00 PM

0

On 1/3/2013 12:20 PM, James Meyers wrote:
> "ColdWarDinosaur" <wynnehenry!@yahoo.co.uk> wrote in message
> news:kc4bou$bn4$3@dont-email.me...
>> Thats why conservatives are so messed up. They live in the past. it
>> was Boehner's congress.
>>
>> On 1/3/2013 11:25 AM, BeamMeUpScotty wrote:
>>> On 1/3/2013 10:19 AM, Nickname unavailable wrote:
>>>> "CONSERVATIVE " extremism: Good Riddance to Rottenest Congress in
>>>> History: the 3 worst congresses on record were "CONSERVATIVE" because
>>>> of them, the worst is yet to come
>>>
>>>
>>> *CONSERVATIVE* is by definition "NOT EXTREMISM"
>>>
>>>
>>> Conservatism "if extreme and wild ideas" is NOT being conservative.
>>>
>>>
>>> Conservatism is: NOT changing quickly from the norm in radical ways in
>>> any direction.
>>>
>>>
>>>
>>> Which mean the "extremists are the radical Progressives".
>>>
>>>
>>> And Obama is a Progressive-Socialist radical and Obama and his ilk are
>>> the extremists.
>>>
>>>
>>> Voters Nation wide handed Pelosi her hat and asked her to leave, it's
>>> only her corrupt local politics that kept her in office at all, but on
>>> the National level they let her know she was a Lying Bitch.
>>>
>>
>>
>> --
>> ~~
>> HW
>> __________________
>> The GOP Claim TO Be Christian but:
>> Are Capitalist Extremists.
>> Support Law of the Jungle, Survival of the Richest.
>> Are Racists.
>> Are Pro-War.
>> Are Pro-Torture.
>> Are Pro-Execution.
>> Are Pro-Money-lender.
>> Despise Human Rights.
>> Despise The Poor.
>> Despise Women.
>> Despise the Disabled.
>> They appear to be against everything Jesus stood for.
>> Who are these people really??
> and you are a lying piece of shit. You make a lot of statements now prove
> any of them.

The election results bore them all out. The US voters are not ALL
dumb, ignorant and gullible. They saw what you're all about and voted
NO!. The only reason you have a marginal majority in the house is
because of gerrymandered voting districts and that too will pass...


--
~~
HW
__________________
The GOP Claim TO Be Christian but:
Are Capitalist Extremists.
Support Law of the Jungle, Survival of the Richest.
Are Racists.
Are Pro-War.
Are Pro-Torture.
Are Pro-Execution.
Are Pro-Money-lender.
Despise Human Rights.
Despise The Poor.
Despise Women.
Despise the Disabled.
They appear to be against everything Jesus stood for.
Who are these people really??

Teemu Likonen

1/29/2016 3:09:00 PM

0

Jim Newton [2016-01-29 06:52:44-08] wrote:

> In order to use format to print an integer with leading zeros, I have to
> use something
> like the following
> (format t "~10,'0D" 12)
> which prints
> 0000000012
>
> However, I don't find that in the spec.
> Here is what I found
> http://www.lispworks.com/documentation/HyperSpec/Body/...
> ~mincol,padcharD uses padchar as the pad character instead of space.
>
> It says I can put a patcher between the , and the D. I interpret this
> to mean that the syntax should be the following to define a field of
> width 10 with a pad character of 0: (format t "~10,0D" 12)
>
> But apparently I have to put a ' before the padchar.

It's here:
http://www.lispworks.com/documentation/HyperSpec/Bod...

A directive consists of a tilde, optional prefix parameters
separated by commas, optional colon and at-sign modifiers, and a
single character indicating what kind of directive this is. There is
no required ordering between the at-sign and colon modifier. The
case of the directive character is ignored. Prefix parameters are
notated as signed (sign is optional) decimal numbers, or as a
single-quote followed by a character. For example, ~5,'0d can be
used to print an integer in decimal radix in five columns with
leading zeros, or ~5,'*d to get leading asterisks.

So the default interpretation is decimal number and ' is for characters
("padchar" is character).

--
/// Teemu Likonen - .-.. <https://github.com/tl... //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

Barry Margolin

1/29/2016 3:18:00 PM

0

In article <594d3a28-b982-42dc-8579-293558561954@googlegroups.com>,
Jim Newton <jimka.issy@gmail.com> wrote:

> In order to use format to print an integer with leading zeros, I have to use
> something
> like the following
> (format t "~10,'0D" 12)
> which prints
> 0000000012
>
> However, I don't find that in the spec.
> Here is what I found
> http://www.lispworks.com/documentation/HyperSpec/Body/...
> ~mincol,padcharD uses padchar as the pad character instead of space.
>
> It says I can put a patcher between the , and the D.
> I interpret this to mean that the syntax should be the following
> to define a field of width 10 with a pad character of 0: (format t "~10,0D"
> 12)
>
> But apparently I have to put a ' before the padchar.
>
> Can someone explain this to me.
>
> Thanks.

If you use 0 without the quote, it means the number 0, not the character
0. This is explained in the more general documentation of FORMAT
parameters:

http://www.lispworks.com/documentation/HyperSpec/Bod...

"Prefix parameters are notated as signed (sign is optional) decimal
numbers, or as a single-quote followed by a character. For example,
~5,'0d can be used to print an integer in decimal radix in five columns
with leading zeros, or ~5,'*d to get leading asterisks."

However, the spec doesn't say what it means to use a number rather than
a character as a pad character, so using an unquoted character is
undefined, and an implementation can interpret it as it sees fit. It
could use its printed representation, in which case it would work the
way you expected. But another plausible interpretation would be to treat
it as a character code, converting it with INT-CHAR.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Jim Newton

1/29/2016 3:56:00 PM

0

On Friday, January 29, 2016 at 4:09:37 PM UTC+1, Teemu Likonen wrote:

>
> It's here:
> http://www.lispworks.com/documentation/HyperSpec/Bod...
>
> A directive consists of a tilde, optional prefix parameters
> separated by commas, optional colon and at-sign modifiers, and a
> single character indicating what kind of directive this is. There is
> no required ordering between the at-sign and colon modifier. The
> case of the directive character is ignored. Prefix parameters are
> notated as signed (sign is optional) decimal numbers, or as a
> single-quote followed by a character. For example, ~5,'0d can be
> used to print an integer in decimal radix in five columns with
> leading zeros, or ~5,'*d to get leading asterisks.
>
> So the default interpretation is decimal number and ' is for characters
> ("padchar" is character).
>

Great! thanks. Reading the spec for FORMAT is one of my least favorite things in the
spec to read. First place (i.e. least favorite) of course goes to LOOP.

It would have been nice if padchar had been a hyperlink to its definition.