Law of cosines - triples: Difference between revisions

Content added Content deleted
(Added solution for Action!)
m (→‎{{header|R}}: Syntax highlighting.)
Line 2,161: Line 2,161:
=={{header|R}}==
=={{header|R}}==
This looks a bit messy, but it really pays off when you see how nicely the output prints.
This looks a bit messy, but it really pays off when you see how nicely the output prints.
<lang R>inputs <- cbind(combn(1:13, 2), rbind(seq_len(13), seq_len(13)))
<lang rsplus>inputs <- cbind(combn(1:13, 2), rbind(seq_len(13), seq_len(13)))
inputs <- cbind(A = inputs[1, ], B = inputs[2, ])[sort.list(inputs[1, ]),]
inputs <- cbind(A = inputs[1, ], B = inputs[2, ])[sort.list(inputs[1, ]),]
Pythagoras <- inputs[, "A"]^2 + inputs[, "B"]^2
Pythagoras <- inputs[, "A"]^2 + inputs[, "B"]^2