Programming Search⌘K

Taskintro

Create an array

Also called make an array, initialize an array, allocate an array, fill an array, new array, array of n copies, declare an array.

Make an array of a given length, with listed values or with one value in each slot, as a fixed array or as a growable one.

Task

Make an array of n items in which each item is value. The function filled(n, value) returns the new array. For example, filled(3, 7) is [7, 7, 7], and filled(0, 7) is the empty array [].

The count n is from 0 to 1000, and value is a 32-bit signed integer. The task also shows the two other common ways to make an array: from a list of values, and with the default value of the item type.

Solutions

Language From values n copies of a value Growable
Python [1, 2, 3] [value] * n a list grows with append
JavaScript, TypeScript [1, 2, 3] new Array(n).fill(value) an array grows with push
Java new int[] {1, 2, 3} new int[n] and Arrays.fill new ArrayList<>(List.of(1, 2, 3))
C# [1, 2, 3] or new[] { 1, 2, 3 } new int[n] and Array.Fill new List<int> { 1, 2, 3 }
Go [3]int{1, 2, 3} make([]int, n) and a loop a slice grows with append
Rust [1, 2, 3] vec![value; n] vec![1, 2, 3]
C int a[] = {1, 2, 3}; malloc and a loop realloc
C++ std::array{1, 2, 3} std::vector<int>(n, value) std::vector<int>{1, 2, 3}
Bash a=(1 2 3) a loop with a+=("$value") an array grows with +=
  • Python. [value] * n repeats the list. "Values of n less than 0 are treated as 0"1, so a negative count gives an empty list and no error.
  • JavaScript. new Array(n) with one integer argument "returns a new JavaScript array with its length property set to that number"2, but the slots are empty. fill puts a value in each slot.
  • Java. "Each class variable, instance variable, or array component is initialized with a default value when it is created"3. So new int[n] holds n zeros, and Arrays.fill then sets each item.
  • C#. "Elements that you don't initialize are set to the default value"4. So new int[n] holds n zeros.
  • Go. make(T, n) gives a "slice of type T with length n and capacity n"5, and each item is the zero value of the type.
  • Rust. vec![value; n] "supports all elements which implement Clone and the number of elements doesn’t have to be a constant"6. An array [value; N] needs a constant N.
  • C. The function returns memory from malloc, and the caller must free it.
  • C++. std::vector<int>(n, value) "Constructs a vector with count copies of elements with value value"7. Use parentheses here, not braces (see the pitfalls).
  • Bash. "Arrays are assigned using compound assignments of the form name=(value1 value2 ... )"8. A Bash array holds strings, so the solution prints one item on each line.

Edge cases

The cases are in cases/basic.jsonl and cases/edge.jsonl.

  • empty: a count of 0 gives an empty array. In C, "If size is zero, the behavior of malloc is implementation-defined"9, so the solution asks for room for one item. Then a null pointer always means that the allocation failed.
  • single: a count of 1 gives one item.
  • zero: an array of zeros is the same as an array with the default value in Java, C#, Go and C.
  • negative and limit: the value can be negative, and it can be the largest or the smallest 32-bit signed integer.
  • many: a count of 10 gives 10 equal items.

Pitfalls

  • Python does not reject a negative count. [7] * -2 is an empty list. Check n first when a negative count is a bug:
print([7] * 3)
print([7] * 0)
print([7] * -2)
Output
[7, 7, 7]
[]
[]
  • JavaScript new Array(n) has empty slots. "This implies an array of arrayLength empty slots, not slots with actual undefined values"2. In the example, map leaves the empty slots empty. With a string argument, new Array("3") is an array of one item. Use fill or Array.from:
const a = new Array(3);
console.log(a.length, 0 in a);
console.log(a.map(() => 7));
console.log(new Array(3).fill(7));
console.log(Array.from({ length: 3 }, (_, i) => i * 10));
console.log(new Array("3"));
Output
3 false
[ <3 empty items> ]
[ 7, 7, 7 ]
[ 0, 10, 20 ]
[ '3' ]
  • Java Arrays.asList has a fixed size. It "Returns a fixed-size list backed by the specified array"10. The list "implements the optional Collection methods, except those that would change the size of the returned list"10, so set works and add throws. Copy it into an ArrayList to get a list that grows:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    int[] zeros = new int[3];
    String[] names = new String[2];
    System.out.println(Arrays.toString(zeros) + " " + Arrays.toString(names));
    List<Integer> fixed = Arrays.asList(1, 2, 3);
    fixed.set(0, 9);
    System.out.println(fixed);
    try {
      fixed.add(4);
    } catch (UnsupportedOperationException e) {
      System.out.println("UnsupportedOperationException");
    }
    List<Integer> growable = new ArrayList<>(Arrays.asList(1, 2, 3));
    growable.add(4);
    System.out.println(growable);
  }
}
Output
[0, 0, 0] [null, null]
[9, 2, 3]
UnsupportedOperationException
[1, 2, 3, 4]
  • C# new List(n) is empty. The constructor makes a list "that is empty and has the specified initial capacity"11. The capacity is room, not items, so list[0] = 7 throws. Use an array, or add the items:
var list = new List<int>(3);
Console.WriteLine($"Count={list.Count} Capacity={list.Capacity}");
try
{
    list[0] = 7;
}
catch (ArgumentOutOfRangeException)
{
    Console.WriteLine("ArgumentOutOfRangeException");
}
int[] a = new int[3];
Array.Fill(a, 7);
Console.WriteLine(string.Join(",", a));
Console.WriteLine(string.Join(",", Enumerable.Repeat(7, 3).ToList()));
Output
Count=0 Capacity=3
ArgumentOutOfRangeException
7,7,7
7,7,7
  • Go append after make(n) adds after the zeros. make([]int, 3) already has 3 items, so append makes the fourth one. To fill a slice with append, make it with length 0 and a capacity, make([]int, 0, n):
package main

import "fmt"

func main() {
	s := make([]int, 3)
	s = append(s, 7)
	fmt.Println(s, len(s))
	t := make([]int, 0, 3)
	t = append(t, 7)
	fmt.Println(t, len(t), cap(t))
}
Output
[0 0 0 7] 4
[7] 1 3
  • Rust vec! clones one value. "vec![Rc::new(1); 5] will create a vector of five references to the same boxed integer value, not five references pointing to independently boxed integers"6. In the example, a change to the first item shows in all three. Make each item with its own call:
use std::cell::RefCell;
use std::rc::Rc;

fn main() {
    let shared = vec![Rc::new(RefCell::new(0)); 3];
    *shared[0].borrow_mut() += 1;
    let values: Vec<i32> = shared.iter().map(|c| *c.borrow()).collect();
    println!("{values:?} owners={}", Rc::strong_count(&shared[0]));
    let own: Vec<Rc<RefCell<i32>>> = (0..3).map(|_| Rc::new(RefCell::new(0))).collect();
    *own[0].borrow_mut() += 1;
    let values: Vec<i32> = own.iter().map(|c| *c.borrow()).collect();
    println!("{values:?} owners={}", Rc::strong_count(&own[0]));
}
Output
[1, 1, 1] owners=3
[1, 0, 0] owners=1
  • C {1} sets only the first item. "All array elements that are not initialized explicitly are empty-initialized"12, so int a[5] = {1} holds one 1 and four zeros. To put 1 in each item, use a loop:
#include <stdio.h>

static void show(const int *a, size_t n) {
    for (size_t i = 0; i < n; i++) {
        printf("%d%s", a[i], i + 1 < n ? " " : "\n");
    }
}

int main(void) {
    int a[5] = {1};
    show(a, 5);
    int b[5];
    for (size_t i = 0; i < 5; i++) {
        b[i] = 1;
    }
    show(b, 5);
    return 0;
}
Output
1 0 0 0 0
1 1 1 1 1
  • C++ braces pick the initializer_list constructor. For list-initialization, "All constructors that take std::initializer_list as the only argument, or as the first argument if the remaining arguments have default values, are examined"13 first. So std::vector<int>{3, 7} holds the two items 3 and 7, and std::vector<int>(3, 7) holds three sevens:
#include <iostream>
#include <vector>

static void show(const char *name, const std::vector<int> &v) {
    std::cout << name << " size=" << v.size() << ":";
    for (int x : v) {
        std::cout << " " << x;
    }
    std::cout << "\n";
}

int main() {
    show("parens", std::vector<int>(3, 7));
    show("braces", std::vector<int>{3, 7});
}
Output
parens size=3: 7 7 7
braces size=2: 3 7
  • Bash splits an unquoted value into words. "Each value in the list undergoes the shell expansions"8, and word splitting is one of them. In the example, s holds a b. The assignment a=($s) makes two items, and b gets one item, because its value is in double quotes. To read the lines of a command into an array, use mapfile -t:
s="a b"
a=($s)
b=("$s")
echo "${#a[@]} ${#b[@]}"
mapfile -t c < <(printf '%s\n' x y z)
echo "${#c[@]} ${c[1]}"
Output
2 1
3 y

Code

The build runs the native tests of each language in a pinned toolchain.

filled.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-an-array/.

def filled(n: int, value: int) -> list[int]:
    """Return a new list of n items, and each item is value."""
    # Repetition copies the reference to value. An int cannot change, so the
    # shared reference does no harm here.
    return [value] * n
test_filled.py 24 lines
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-an-array/.

import pytest

from filled import filled

CASES = {
    "three-sevens": (3, 7, [7, 7, 7]),
    "five-zeros": (5, 0, [0, 0, 0, 0, 0]),
    "empty": (0, 7, []),
    "single": (1, 42, [42]),
    "zero": (2, 0, [0, 0]),
    "negative": (2, -1, [-1, -1]),
    "max-int": (2, 2147483647, [2147483647, 2147483647]),
    "min-int": (2, -2147483648, [-2147483648, -2147483648]),
    "ten": (10, 1, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),
}


@pytest.mark.parametrize("name", CASES)
def test_filled(name):
    n, value, want = CASES[name]
    assert filled(n, value) == want
filled.cppI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

#include "filled.hpp"

#include <cstddef>
#include <vector>

std::vector<int> filled(std::size_t n, int value) {
    // Parentheses call the (count, value) constructor. Braces would make a
    // vector of the two items n and value.
    return std::vector<int>(n, value);
}
filled.hpp 10 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

#pragma once

#include <cstddef>
#include <vector>

// filled returns a new vector of n items, and each item is value.
std::vector<int> filled(std::size_t n, int value);
test_filled.cpp 36 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

#include "filled.hpp"

#include <climits>
#include <cstddef>
#include <iostream>
#include <string_view>
#include <vector>

static int failures = 0;

static void check(std::string_view name, std::size_t n, int value) {
    if (filled(n, value) != std::vector<int>(n, value) || filled(n, value).size() != n) {
        std::cerr << "case " << name << " failed\n";
        failures++;
    }
}

int main() {
    check("three-sevens", 3, 7);
    check("five-zeros", 5, 0);
    check("empty", 0, 7);
    check("single", 1, 42);
    check("zero", 2, 0);
    check("negative", 2, -1);
    check("max-int", 2, INT_MAX);
    check("min-int", 2, INT_MIN);
    check("ten", 10, 1);
    if (failures > 0) {
        return 1;
    }
    std::cout << "all cases pass\n";
    return 0;
}
Filled.javaI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

import java.util.Arrays;

final class Filled {
  private Filled() {}

  /** Returns a new array of n items, and each item is value. */
  static int[] filled(int n, int value) {
    // new int[n] holds n zeros. fill then sets each item.
    int[] a = new int[n];
    Arrays.fill(a, value);
    return a;
  }
}
FilledTest.java 30 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class FilledTest {
  static Stream<Arguments> cases() {
    return Stream.of(
        Arguments.of("three-sevens", 3, 7, new int[] {7, 7, 7}),
        Arguments.of("five-zeros", 5, 0, new int[] {0, 0, 0, 0, 0}),
        Arguments.of("empty", 0, 7, new int[] {}),
        Arguments.of("single", 1, 42, new int[] {42}),
        Arguments.of("zero", 2, 0, new int[] {0, 0}),
        Arguments.of("negative", 2, -1, new int[] {-1, -1}),
        Arguments.of("max-int", 2, 2147483647, new int[] {2147483647, 2147483647}),
        Arguments.of("min-int", 2, Integer.MIN_VALUE, new int[] {Integer.MIN_VALUE, Integer.MIN_VALUE}),
        Arguments.of("ten", 10, 1, new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}));
  }

  @ParameterizedTest(name = "{0}")
  @MethodSource("cases")
  void filled(String name, int n, int value, int[] want) {
    assertArrayEquals(want, Filled.filled(n, value));
  }
}
filled.cI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

#include "filled.h"

#include <stdlib.h>

int *filled(size_t n, int value) {
    // malloc(0) may return NULL or a pointer, so ask for at least one item.
    // Then NULL always means that the allocation failed.
    int *a = malloc((n > 0 ? n : 1) * sizeof *a);
    if (a == NULL) {
        return NULL;
    }
    for (size_t i = 0; i < n; i++) {
        a[i] = value;
    }
    return a;
}
filled.h 13 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

#ifndef FILLED_H
#define FILLED_H

#include <stddef.h>

// filled returns a new array of n ints, and each item is value. The caller
// must free the array. It returns NULL when the allocation fails.
int *filled(size_t n, int value);

#endif
test_filled.c 40 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

#include "filled.h"

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

static int failures = 0;

static void check(const char *name, size_t n, int value) {
    int *a = filled(n, value);
    int ok = a != NULL;
    for (size_t i = 0; ok && i < n; i++) {
        ok = a[i] == value;
    }
    if (!ok) {
        fprintf(stderr, "case %s failed\n", name);
        failures++;
    }
    free(a);
}

int main(void) {
    check("three-sevens", 3, 7);
    check("five-zeros", 5, 0);
    check("empty", 0, 7);
    check("single", 1, 42);
    check("zero", 2, 0);
    check("negative", 2, -1);
    check("max-int", 2, INT_MAX);
    check("min-int", 2, INT_MIN);
    check("ten", 10, 1);
    if (failures > 0) {
        return 1;
    }
    printf("all cases pass\n");
    return 0;
}
Filled.csI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

using System;

public static class Filled
{
    // new int[n] holds n zeros. Array.Fill then sets each item.
    public static int[] Create(int n, int value)
    {
        var a = new int[n];
        Array.Fill(a, value);
        return a;
    }
}
FilledTests.cs 28 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

using Xunit;

public sealed class FilledTests
{
    public static TheoryData<string, int, int, int[]> Cases => new()
    {
        { "three-sevens", 3, 7, new int[] { 7, 7, 7 } },
        { "five-zeros", 5, 0, new int[] { 0, 0, 0, 0, 0 } },
        { "empty", 0, 7, new int[0] },
        { "single", 1, 42, new int[] { 42 } },
        { "zero", 2, 0, new int[] { 0, 0 } },
        { "negative", 2, -1, new int[] { -1, -1 } },
        { "max-int", 2, 2147483647, new int[] { 2147483647, 2147483647 } },
        { "min-int", 2, int.MinValue, new int[] { int.MinValue, int.MinValue } },
        { "ten", 10, 1, new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } },
    };

    [Theory]
    [MemberData(nameof(Cases))]
    public void Check(string name, int n, int value, int[] want)
    {
        Assert.NotNull(name);
        Assert.Equal(want, Filled.Create(n, value));
    }
}
filled.jsI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

/**
 * @param {number} n
 * @param {number} value
 * @returns {number[]}
 */
export function filled(n, value) {
  // new Array(n) has n empty slots. fill puts value in each one.
  return new Array(n).fill(value);
}
filled.test.js 25 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

import assert from "node:assert/strict";
import { test } from "node:test";

import { filled } from "./filled.js";

const cases = [
  ["three-sevens", 3, 7, [7, 7, 7]],
  ["five-zeros", 5, 0, [0, 0, 0, 0, 0]],
  ["empty", 0, 7, []],
  ["single", 1, 42, [42]],
  ["zero", 2, 0, [0, 0]],
  ["negative", 2, -1, [-1, -1]],
  ["max-int", 2, 2147483647, [2147483647, 2147483647]],
  ["min-int", 2, -2147483648, [-2147483648, -2147483648]],
  ["ten", 10, 1, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],
];

for (const [name, n, value, want] of cases) {
  test(name, () => {
    assert.deepEqual(filled(n, value), want);
  });
}
filled.tsI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

export function filled(n: number, value: number): number[] {
  // Array.from calls the function once for each index, so no slot is empty.
  return Array.from({ length: n }, () => value);
}
filled.test.ts 25 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

import assert from "node:assert/strict";
import { test } from "node:test";

import { filled } from "./filled.ts";

const cases: [string, number, number, number[]][] = [
  ["three-sevens", 3, 7, [7, 7, 7]],
  ["five-zeros", 5, 0, [0, 0, 0, 0, 0]],
  ["empty", 0, 7, []],
  ["single", 1, 42, [42]],
  ["zero", 2, 0, [0, 0]],
  ["negative", 2, -1, [-1, -1]],
  ["max-int", 2, 2147483647, [2147483647, 2147483647]],
  ["min-int", 2, -2147483648, [-2147483648, -2147483648]],
  ["ten", 10, 1, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],
];

for (const [name, n, value, want] of cases) {
  test(name, () => {
    assert.deepEqual(filled(n, value), want);
  });
}
filled.goI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

// Package createarray makes a slice of n equal items.
package createarray

// Filled returns a new slice of n items, and each item is value.
func Filled(n int, value int) []int {
	// make gives n zeros. The loop then sets each item.
	a := make([]int, n)
	for i := range a {
		a[i] = value
	}
	return a
}
filled_test.go 34 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

package createarray

import (
	"slices"
	"testing"
)

var cases = []struct {
	name  string
	n     int
	value int
	want  []int
}{
	{"three-sevens", 3, 7, []int{7, 7, 7}},
	{"five-zeros", 5, 0, []int{0, 0, 0, 0, 0}},
	{"empty", 0, 7, []int{}},
	{"single", 1, 42, []int{42}},
	{"zero", 2, 0, []int{0, 0}},
	{"negative", 2, -1, []int{-1, -1}},
	{"max-int", 2, 2147483647, []int{2147483647, 2147483647}},
	{"min-int", 2, -2147483648, []int{-2147483648, -2147483648}},
	{"ten", 10, 1, []int{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}},
}

func TestFilled(t *testing.T) {
	for _, c := range cases {
		if got := Filled(c.n, c.value); len(got) != c.n || !slices.Equal(got, c.want) {
			t.Errorf("%s: got %v, want %v", c.name, got, c.want)
		}
	}
}
filled.rsI0RawGitHub
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

/// Returns a new vector of n items, and each item is value.
pub fn filled(n: usize, value: i32) -> Vec<i32> {
    // vec! clones value n times. For i32 a clone is a copy.
    vec![value; n]
}
tests/filled_test.rs 22 lines
// SPDX-License-Identifier: MIT
// Part of https://programming.tamnd.com/create-an-array/.

use algo_create_an_array::filled;

#[test]
fn cases() {
    let cases: &[(&str, usize, i32, &[i32])] = &[
        ("three-sevens", 3, 7, &[7, 7, 7]),
        ("five-zeros", 5, 0, &[0, 0, 0, 0, 0]),
        ("empty", 0, 7, &[]),
        ("single", 1, 42, &[42]),
        ("zero", 2, 0, &[0, 0]),
        ("negative", 2, -1, &[-1, -1]),
        ("max-int", 2, 2147483647, &[2147483647, 2147483647]),
        ("min-int", 2, i32::MIN, &[i32::MIN, i32::MIN]),
        ("ten", 10, 1, &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),
    ];
    for &(name, n, value, want) in cases {
        assert_eq!(filled(n, value), want, "{name}");
    }
}
filled.shI0RawGitHub
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-an-array/.

# filled N VALUE
# Prints VALUE N times, one on each line. A Bash array holds strings, so the
# lines stand for the items of the array.
filled() {
  local -a a=()
  local i
  for ((i = 0; i < $1; i++)); do
    a+=("$2")
  done
  if ((${#a[@]} > 0)); then printf '%s\n' "${a[@]}"; fi
}
test_filled.bats 32 lines
#!/usr/bin/env bats
# SPDX-License-Identifier: MIT
# Part of https://programming.tamnd.com/create-an-array/.

bats_require_minimum_version 1.5.0

setup() {
  source "$BATS_TEST_DIRNAME/filled.sh"
}

lines() { # lines ITEM...: prints each item on a line, and nothing for no items
  if (($# > 0)); then printf '%s\n' "$@"; fi
}

check() { # check N VALUE -- WANT...
  local n=$1 value=$2 got want
  shift 3
  # The x keeps the trailing newlines, which $(...) removes.
  got=$(filled "$n" "$value"; printf x)
  want=$(lines "$@"; printf x)
  [ "$got" = "$want" ] || { printf 'got:  %q\nwant: %q\n' "$got" "$want"; return 1; }
}

@test "three-sevens" { check 3 7 -- 7 7 7; }
@test "five-zeros" { check 5 0 -- 0 0 0 0 0; }
@test "empty" { check 0 7 --; }
@test "single" { check 1 42 -- 42; }
@test "zero" { check 2 0 -- 0 0; }
@test "negative" { check 2 -1 -- -1 -1; }
@test "max-int" { check 2 2147483647 -- 2147483647 2147483647; }
@test "min-int" { check 2 -2147483648 -- -2147483648 -2147483648; }
@test "ten" { check 10 1 -- 1 1 1 1 1 1 1 1 1 1; }

References

  1. The Python Standard Library, Built-in Types, Common Sequence Operations, note 2
  2. MDN Web Docs, Array() constructor, Parameters, arrayLength
  3. The Java Language Specification, Java SE 25 Edition, 4.12.5 Initial Values of Variables
  4. C# language reference, Arrays, Single-dimensional arrays
  5. The Go Programming Language Specification, Making slices, maps and channels
  6. Rust standard library, macro vec, Description
  7. cppreference.com, std::vector constructors, 4)
  8. Bash Reference Manual, 6.7 Arrays
  9. cppreference.com, malloc, Description
  10. Java SE 25 API, Class Arrays, asList
  11. .NET API reference, List<T> constructors, List<T>(Int32)
  12. cppreference.com, C array initialization, Explanation
  13. cppreference.com, List-initialization, Explanation

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (bash)I0 not checked yet
  • the tests did not run in this build
Code (c)I0 not checked yet
  • the tests did not run in this build
Code (cpp)I0 not checked yet
  • the tests did not run in this build
Code (csharp)I0 not checked yet
  • the tests did not run in this build
Code (go)I0 not checked yet
  • the tests did not run in this build
Code (java)I0 not checked yet
  • the tests did not run in this build
Code (javascript)I0 not checked yet
  • the tests did not run in this build
Code (python)I0 not checked yet
  • the tests did not run in this build
Code (rust)I0 not checked yet
  • the tests did not run in this build
Code (typescript)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW3 standard
  • a history with a source