In Haskell, if I wanted to get a 10 element list which only contained the number 5, I could do something like this:
take 10 $ repeat 5
Outp
The ones method is much faster than using repmat:
>> tic; for i = 1:1e6, x=5*ones(10,1); end; toc Elapsed time is 3.426347 seconds. >> tic; for i = 1:1e6, y=repmat(5,10,1); end; toc Elapsed time is 20.603680 seconds.
And, in my opinion, makes for much more readable code.