For Programmers: Free Programming Magazines  


Home > Archive > Lisp > May 2004 > "bestN" format directive?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author "bestN" format directive?
Steve Eichblatt

2004-05-20, 1:33 pm

Hi All,

I am fairly new to Lisp, so forgive me if this is too simple.

I am trying to write a small library to do data joining and plotting in
Common Lisp, using all the good things from other plotting programs i've
used and excluding the bad things.

There is a good idea from a program called SAS that i would like to
borrow. I would like to print an object in a format similar to SAS's
"bestN", where N is some number of digits.

So for example, you could format an object to best9, and it would print
the object in the "best" 9 characters possible. So if it is a small
integer, it just prints it with padding. If it's a float with alot of
significant digits, it rounds it. If it's a very large or very small
number, it puts it in exponential notation, and if it's a string less
than 9 characters, it prints it, else use an overflow character 9 times.
In all cases, you're guaranteed to have exactly than 9 (or N)
characters. It is a lot like the ~nA format directive, except ~nA
guarantees only a minimum, and not a maximum number of characters.

Perhaps this format directive is already available within Common Lisp.
Any ideas would be appreciated.

Thanks,

Steve Eichblatt

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com