Logo

Programming-Idioms

History of Idiom 7 > diff from v66 to v67

Edit summary for version 67 by andrepd:
New Caml implementation by user [andrepd]

Version 66

2019-09-26, 15:06:45

Version 67

2019-09-26, 16:49:33

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Extra Keywords
traverse traversal
Extra Keywords
traverse traversal
Code
(* output_elem is a printer for elements of [items] *)
items |> List.iteri (fun i x ->
	printf "%d: %a" i output_elem x
)