That programming book you never finished

Arik on June 22, 2018

Tell me if this sounds familiar: You walk into a bookstore, browse through some shelves and run into a programming book about a subject you al... [Read Full]
markdown guide

Based on the opening, I was looking for strategies on finishing books.


Use iterators:


or mappers:

or even reducers:

pages.reduce([]) { |knowledge, page| knowledge << page }

Try reducing computation by finding a closed form instead of writing a loop. Here, the closed form is f(n) = n*(n+1) (e.g. f(100) = 100*101 = 10100):

f(n) = S[1..n] 2*i     definition
     = 2 * S[1..n] i   pull out the coefficient
     = 2 * n*(n+1)/2   by triangular number formula
     = n*(n+1)         cancel the twos

Personally I would think the following is the exact translation in Python of the math formula shown in the article:

  sum(2*i for i in range(1, 101))

(well... if you ignore the fact that the upper limit of range in not inclusive so I need to put 101 instead of 100)

So now that you know about Sigmas etc. you can read The Art of Computer Programming ;-)


Not the topic I expected, bit was a nice read anyway.


I recommend this site for math and science stuff :) is a "cheatsheet" explaining tons of math notation by showing equivalent JavaScript code, similar to how this article explained Σ.


Mathematical Notation: A Guide for Engineers and Scientists
I bought this little jewel just for this situation:


The rabbit hole in question.

I'm surprised they're not teaching this in school anymore.


Misleading headline. But now high school math is coming back to me...

code of conduct - report abuse