Logo

Programming-Idioms

# 243 Print list
Print the contents of the list or array a on the standard output.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
(print a)
#include <algorithm>
#include <iostream>
#include <iterator>
std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout, "\n"));
Console.WriteLine( string.Join(", ", a) );
a.ForEach(Console.WriteLine);
print(a);
Enum.each(a, &IO.inspect/1)
write (*,*) a
import "fmt"
fmt.Println(a)
print a
console.table(a);
console.log(a);
import java.util.Arrays;
System.out.println(Arrays.toString(a));
import java.util.List;
System.out.println(a);
(defun plist (lst)
  (if (< (length lst) 20 )  
      (loop for elem in lst do (p elem))
      (let ((l (length lst )))
         (p (nth 0 lst )(nth 1 lst )(nth 2 lst )(nth 3 lst )
         "... (" l " in total)... "
         (nth (- l 4) lst )(nth (- l 3 ) lst )(nth (- l 2 ) lst )(nth (- l 1 ) lst ) )
      )))

(defun p (x &rest others)
  (cond ((listp x)( plist x   ))
        ((stringp x)(format t x  ))
        (T (write x)))
  (format t " ") 
  (if others (p others))
(print a )
print(table.concat(a,", "))
print_r($a)
for el in a do writeln(el);
print "@items\n";
print join(', ', @items) . "\n";
print(a)
puts a * ", "
puts a.join(", ")
puts a
println!("{:?}", a)
(write a)