flâneur — a map of the web's best reading

Reading 1: Static Checking

web.mit.edu · 5,247 words · saved by 1 readers

As a running example, we’re going to explore the hailstone sequence, which is defined as follows: Starting with a number n, the next number in the sequence is n/2 if n is even, or 3n+1 if n is odd. The sequence ends when it reaches 1. Here are some examples: 2, 1 3, 10, 5, 16, 8, 4, 2, 1 4, 2, 1 2n, 2n-1 , … , 4, 2, 1 5, 16, 8, 4, 2, 1 7, 22, 11, 34, 17, 52, 26, 13, 40, …? (where does this stop?) Because of the odd-number rule, the sequence may bounce up and down before decreasing to 1. It’s conjectured that all hailstones eventually fall to the ground – i.e., the hailstone sequence reaches 1 for all starting n – but that’s still an open question. Why is it called a hailstone sequence? Because hailstones form in clouds by bouncing up and down until they eventually build enough weight to fall to earth. Here’s some code for computing and printing the hailstone sequence for some starting n. We’ll write JavaScript and Python versions of the code side by side for comparison: The basic seman

Reading 1: Static Checking Reading 1: Static Checking Objectives Today’s class has two topics: static typing the big three properties of good software Hailstone sequence As a running example, we’re going to explore the hailstone sequence, which is defined as follows: Starting with a number n , the next number in the sequence is n/2 if n is even, or 3n+1 if n is odd. The sequence ends when it reaches 1. Here are some examples: 2, 1 3, 10, 5, 16, 8, 4, 2, 1 4, 2, 1 2 n , 2 n-1 , … , 4, 2, 1 5, 16, 8, 4, 2, 1 7, 22, 11, 34, 17, 52, 26, 13, 40, …? (where does this stop?) Because of the odd-number

Explore this link on the map →

related reading