Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
Select your favorite languages :
  • Or search :

Idiom #284 Created a zeroed list of integers

Create a new list a (or array, or slice) of size n, where all elements are integers initialized with the value 0.

let a = vec![0; n];
integer, dimension(:), allocatable :: a

allocate(a(n),source = 0)
a := make([]int, n)
a = replicate n 0
const a = new Array(n).fill(0);
a := nil;
setlength(a, n);
a = [0] * n
a = Array.new(n, 0)
a = [0] * n

New implementation...
programming-idioms.org