Distance matrix between points

Exercise Type: Implementation

Consider the following points

points <- matrix(c(
	1,4,
	2,2,
	3,1,
	0, -1
), ncol=2, byrow=TRUE)
rownames(points) <- letters[1:4]
colnames(points) <- c("x", "y")
points
  x  y
a 1  4
b 2  2
c 3  1
d 0 -1

Instructions

Calculate a distance matrix between these points! Use the function distance() that was defined here. Instead of relying on manual repetition of instructions, use iteration (for loops). The matrix should have exactly 16 values, with a dim attribute of c(4,4).

Hint: the elegant solution to the problem involves two for loops, one nested in the other!