Logo

Programming-Idioms

  • Clojure
(doseq [[i x] (map-indexed vector items)]
  (println i ":" x))

items can be any Clojure collection (vector, list, set, map). We construct a new sequence which contains in each element the index of each one and its original value in items. doseq is used for side-effects.
with Ada.Text_IO;
use Ada.Text_IO;
for I in Items'Range loop
   X := Items (I);
   Put_Line (Integer'Image (I) & " " & Integer'Image (X));
end loop;

Assuming Items is an array of integers.

New implementation...