Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Prolog

Idiom #314 Fill array with value

Set all the elements in the array x to the same value v

set_all_elements_to_same_value(X, V) :-
    length(X, Length),
    length(FilledList, Length),
    maplist(=(V), FilledList, X).
#include <array>
x.fill(v);

New implementation...