Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (52 sloc) 2.576 kb
60141844 »
2002-08-03 * Implemented FORMAT-TEXTUAL-LIST.
1 ;;; -*- Mode: Lisp; Package: CLIM-INTERNALS -*-
2
3 ;;; (c) copyright 2002 by Alexey Dejneka (adejneka@comail.ru)
4
5 ;;; This library is free software; you can redistribute it and/or
6 ;;; modify it under the terms of the GNU Library General Public
7 ;;; License as published by the Free Software Foundation; either
8 ;;; version 2 of the License, or (at your option) any later version.
9 ;;;
10 ;;; This library is distributed in the hope that it will be useful,
11 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ;;; Library General Public License for more details.
14 ;;;
15 ;;; You should have received a copy of the GNU Library General Public
16 ;;; License along with this library; if not, write to the
17 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 ;;; Boston, MA 02111-1307 USA.
19
20 ;;; TODO:
21 ;;;
22 ;;; - INDENTING-OUTPUT
23 ;;;
24 ;;; - FILLING-OUTPUT
25
26 (in-package :CLIM-INTERNALS)
27
28 (defun format-textual-list (sequence printer
29 &key stream separator conjunction
30 suppress-separator-before-conjunction
31 suppress-space-after-conjunction)
32 "Outputs the SEQUENCE of items as a \"textual list\" into
33 STREAM. PRINTER is a function of an item and a stream. Between each
34 two items the string SEPARATOR is placed. If the string CONJUCTION is
35 supplied, it is placed before the last item.
36
37 SUPPRESS-SEPARATOR-BEFORE-CONJUNCTION and
38 SUPPRESS-SPACE-AFTER-CONJUNCTION are non-standard."
39 (orf stream *standard-output*)
40 (orf separator ", ")
41 (let* ((length (length sequence))
42 (n-rest length))
43 (map-repeated-sequence nil 1
44 (lambda (item)
45 (funcall printer item stream)
46 (decf n-rest)
47 (cond ((> n-rest 1)
48 (princ separator stream))
49 ((= n-rest 1)
50 (if conjunction
51 (progn
52 (unless suppress-separator-before-conjunction
53 (princ separator stream))
54 (princ conjunction stream)
55 (unless suppress-space-after-conjunction
56 (princ #\space stream)))
57 (princ separator stream)))))
58 sequence)))
Something went wrong with that request. Please try again.