August 2015
Intermediate to advanced
216 pages
4h 50m
English
Triangles are a particular matrix type. Each line contains exactly as many nonzero elements as the line index in the matrix. Here is a sample triangle depicted as a vector of vectors in Clojure:
[[1 0 0 0 0 0 0] [1 1 0 0 0 0 0] [1 1 1 0 0 0 0] [1 1 1 1 0 0 0] [1 1 1 1 1 0 0] [1 1 1 1 1 1 0] [1 1 1 1 1 1 1]]
Now, we can simply omit the zeros altogether and get a real triangle, graphically speaking:
[[1] [1 1] [1 1 1] [1 1 1 1] [1 1 1 1 1] [1 1 1 1 1 1] [1 1 1 1 1 1 1] [1 1 1 1 1 1 1 1 1]]
Pascal's triangle is a matrix whose elements are computed as the sum of the elements that are directly above it and the element to the left of the elements that are directly above it. The very first element is 1. This matrix ...
Read now
Unlock full access