Skip to main content

Posts

Showing posts from June, 2014

Teaching Math

I recently bought myself a Math book that I'm delighted with (Mathematics 1001 by Elwes). I'm finally understanding many math concepts I had not understood in my education and I've reached an few interesting theories on how math should be taught.

There should be three things that a math class should teach at the same time:
1. Memorization
2. Visual (Graph-Based)
3. Procedural (Equation-Based)
4. Historical

All four are part of a whole and some students will respond better on one than the other. These are four avenues to teach the same thing by the way not three different things.

Memorization should begin really early. There is no need to explain how multiplication works to have the kids start to memorize the multiplication table. The reason is not that you *need* to memorize it but  that by doing so or encouraging kids to do so, they'll be faster at doing calculations. Here are the things I think should be memorized in math:
a. all the pairs of numbers that add up to 1…

Multiple Assignments in Ruby

In this Rails project I'm running I need to set a whole bunch of individual variables to 'disabled' at once depending on the group the current user belongs to. We can use multiple assignment in this case but with a caveat.

Multiple assignments are a quick way of setting a lot of variables at once.

h, k = 1,2  => [1,2]

h => 1
k => 2

but

h, k = 1      => 1

h => 1
k => nil

In that case we can do this:

h = k = 1   => 1

h => 1
h => 1 

Beware this sets them to the same object. So if you change one you change both.

h = k = []
h << 1

h => [1]
k => [1]

While we're at it here is how to reverse two variables:

h = 1
k = 2
h,k = k,h

h => 2
k => 1