Re: [eclipse-clp-users] Possible to use format/2 to print a table with right-justified columns?

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Thu, 21 Aug 2014 14:48:59 +0200
On 21/08/2014 13:21, Paulo Moura wrote:
> Hi,
> 
> Is it possible to use ECLiPSe format/2 predicate to print a table with right-justified columns?
> The original Quintus Prolog implementation of this predicate provide format control sequences to
> set and align with tab stops but this seems to not be implemented in ECLiPSe. Is there any
> alternative usage of the format/2 predicate that I'm missing?


As noted in http://www.eclipseclp.org/doc/bips/lib/format/format-3.html, the lib(format)
implementation is a wrapper for ECLiPSe's printf.  Here is a more detailed comparison:

%
% This is currently just a wrapper for printf/3 to provide the most basic
% features of Quintus-style format/3.  Comparison of capabilities:
%
%	DeFacto	ECLiPSe
%	format	printf
%	~	%
%	
%	a	a	atom
%	-	A	atom in all upper case
%	Nc	Nc	Character code
%	NE	NE	float
%	Ne	Ne	float
%	NF	NF	float
%	Nf	Nf	float
%	NG	NG	float
%	Ng	Ng	float
%	NH	-	float precise
%	Nh	-	float precise
%	-	Ad	integer (as in C)
%	-	Ao	integer in octal
%	-	Au	integer in unsigned decimal??
%	-	Ax	integer in hex a-f
%	-	AX	integer in hex A-F
%	ND	-	integer (inserting decimal point and separator commas)
%	Nd	-	integer (inserting decimal point)
%	NR	NR	radix
%	Nr	Nr	radix
%	Ns	As	code list / string
%	Ni	Ni	ignore
%	Nk	Nk	write_canonical/display
%	p	p	print
%	q	q	writeq
%	w	w	write
%	-	Cw	write/write with control chars
%	-	CW	write/write with stream settings and control chars
%	@	-	call to print
%	~	-	print ~
%	-	%	print %
%	Nn	Nn	newlines
%	N	-	newline if necessary
%	-	Nt	tabs
%	-	b	flush
%	|	-	column printing
%	+	-	column printing
%	t	-	column printing


This is a far as this approach goes, I'm not planning to implement the acrobatics necessary for tty
column printing (tables are much easier with html output).  That said, I'm hoping for a
Prolog-level implementation of a completely compatible format/3 from Prolog Commons.

Cheers,
Joachim
Received on Thu Aug 21 2014 - 12:49:12 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST