PageRenderTime 61ms CodeModel.GetById 35ms RepoModel.GetById 0ms 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. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "cln/GV_complex.h"
  6. #include "cln/GV_real.h"
  7. #include "cln/GV_rational.h"
  8. #include "cln/GV_integer.h"
  9. #include "vector/cl_GV_io.h"
  10. // Implementation.
  11. #include "cln/output.h"
  12. namespace cln {
  13. void 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)
  14. {
  15. std::size_t len = vector.size();
  16. if (flags.vector_syntax == vsyntax_commonlisp) {
  17. fprintchar(stream,'#');
  18. fprintchar(stream,'(');
  19. } else
  20. fprintchar(stream,'[');
  21. for (std::size_t i = 0; i < len; i++) {
  22. if (i > 0) {
  23. if (flags.vector_syntax == vsyntax_algebraic)
  24. fprintchar(stream,',');
  25. fprintchar(stream,' ');
  26. }
  27. // The conversion to cl_number below is needed for SGI CC.
  28. printfun(stream,flags,(cl_number)vector[i]);
  29. }
  30. if (flags.vector_syntax == vsyntax_commonlisp)
  31. fprintchar(stream,')');
  32. else
  33. fprintchar(stream,']');
  34. }
  35. } // namespace cln