PageRenderTime 61ms CodeModel.GetById 15ms app.highlight 35ms RepoModel.GetById 1ms app.codeStats 0ms

/cln-1.3.2/src/vector/output/cl_GV_number_aprint.cc

#
C++ | 43 lines | 30 code | 8 blank | 5 comment | 8 complexity | 34e700d2a99d592cd6b46735bfe2453a MD5 | raw file
Possible License(s): GPL-2.0
 1// print_vector().
 2
 3// General includes.
 4#include "base/cl_sysdep.h"
 5
 6// Specification.
 7#include "cln/GV_complex.h"
 8#include "cln/GV_real.h"
 9#include "cln/GV_rational.h"
10#include "cln/GV_integer.h"
11#include "vector/cl_GV_io.h"
12
13
14// Implementation.
15
16#include "cln/output.h"
17
18namespace cln {
19
20void print_vector (std::ostream& stream, const cl_print_flags& flags, void (* printfun) (std::ostream&, const cl_print_flags&, const cl_number&), const cl_GV_number& vector)
21{
22	std::size_t len = vector.size();
23	if (flags.vector_syntax == vsyntax_commonlisp) {
24		fprintchar(stream,'#');
25		fprintchar(stream,'(');
26	} else
27		fprintchar(stream,'[');
28	for (std::size_t i = 0; i < len; i++) {
29		if (i > 0) {
30			if (flags.vector_syntax == vsyntax_algebraic)
31				fprintchar(stream,',');
32			fprintchar(stream,' ');
33		}
34		// The conversion to cl_number below is needed for SGI CC.
35		printfun(stream,flags,(cl_number)vector[i]);
36	}
37	if (flags.vector_syntax == vsyntax_commonlisp)
38		fprintchar(stream,')');
39	else
40		fprintchar(stream,']');
41}
42
43}  // namespace cln