From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id DFF6ABB81 for ; Fri, 13 Jan 2006 17:28:37 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0DGSbpF018796 for ; Fri, 13 Jan 2006 17:28:37 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA08723 for ; Fri, 13 Jan 2006 17:28:36 +0100 (MET) Received: from rwcrmhc12.comcast.net (rwcrmhc13.comcast.net [216.148.227.153] (may be forged)) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0DGSZQX018793 for ; Fri, 13 Jan 2006 17:28:36 +0100 Received: from 192.168.1.100 (c-24-118-210-113.hsd1.mn.comcast.net[24.118.210.113]) by comcast.net (rwcrmhc13) with SMTP id <2006011316283301500ah7fpe>; Fri, 13 Jan 2006 16:28:33 +0000 Subject: Re: [Caml-list] Request for comments: Printf list conversion From: Bill Wood To: Hendrik Tews Cc: Ocaml In-Reply-To: References: <43C61F1F.4030101@barettadeit.com> <1137081054.29722.13.camel@localhost> Content-Type: text/plain Date: Fri, 13 Jan 2006 10:28:32 -0600 Message-Id: <1137169712.19978.32.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.0.1-1mdk Content-Transfer-Encoding: 7bit X-j-chkmail-Score: MSGID : 43C7D533.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 43C7D535.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43C7D533.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 hendrik:01 tews:01 printf:01 complained:01 separators:01 separators:01 non-empty:01 syntax:01 specifies:01 stdout:01 haskell:01 wrote:01 tail:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Fri, 2006-01-13 at 10:31 +0100, Hendrik Tews wrote: . . . > I doubt anybody will yelp. Having a printf format for 'a list it That would be nice :-). However, even some lispers have complained (with some justification) that writing format forms was like writing TECO macros, or minimalistic Perl. > BTW, what is the common list solution for printing separators > just between the list elements? There is no special provision for separators that I know of. I always just took the cheap way out, first formatting the head of the list and then formatting the tail with a list format that prints the separator and then the next item. A sample transcript in CLISP is* (let ((xs '(0 1 2 3))) (format t "~%>~s~{, ~s~}<~%" (first xs) (rest xs))) >0, 1, 2, 3< This is facilitated by the conditional format directive, allowing different formats depending on whether the list argument is empty or non-empty. -- Bill Wood * The syntax of the CL format form is (format ...) where specifies returning a string, printing to stdout, or printing to a stream, is a string containing format directives together with ordinary characters, and the remaining args are the objects being formatted out. Format directives are prefixed with "~"; the directive "~%" produces a newline and the directive "~s" formats any lisp s-expression, like a Haskell "show x". -- wtw