bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Format by example problems


From: Juergen Sauermann
Subject: Re: [Bug-apl] Format by example problems
Date: Tue, 03 Jun 2014 12:43:59 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi Elias,

I guess you need format characters 1, 2 and/or 3 for that:


      '-12' ⍕ ¯42 42
-42 42

Those cannot be combined with normal text. The decorators are not meant as a shortcut for inserting
text into ⍕ but rather to improve formatting of signed numbers such as -42 or (42) or 42 printed in red,
which used to be common in bookkeeping, instead of the rather uncommon ¯.

You always get a fixed size output, so %d would not work as in printf().
Same for the other dyadic ⍕ variant:

      6 2⍕42
 42.00

This is very much like %6.2d in C.

Generally speaking, use monadic ⍕ for output of variable size and
dyadic ⍕ for columns of fixed size.

I can't really see that ⎕FMT is adding much value, and we also have FILE_IO with printf()
as an alternative.

/// Jürgen


On 06/03/2014 07:43 AM, Elias Mårtenson wrote:
I'm trying to coerce ⍕ into doing something that should be trivial. Assume I have a number N, and I want to display it like in a printf using the pattern "value=%d".

I've tried all sorts of variations, but I just can't make it happen. It's all good until I try to pass in a negative value. How can I do this?

Secondly, it seems to me as though this thing is designed with preformatted columnar data in mind. This kind of formatting is increasingly rare these days, so I still feel that a more powerful formatting facility is needed. Something along the lines of the Common Lisp FORMAT function would be nice.

Regards,
Elias


reply via email to

[Prev in Thread] Current Thread [Next in Thread]