This is another installment in my “reduce” series of posts, aimed at helping programmers understand this function, with examples in both Ruby and Python. So far, we have seen how we can build a number of different types of data structures — integers, strings, arrays, and hashes — using “reduce”. But the really interesting use…
In the last few installments (first, second, third, and fourth) of this series, we saw how “reduce” can be used to build up a scalar value (such as a number or string), or even a simple collection, such as a list (in Python) or an array (in Ruby). The jewel in the data-structure crown for…
In the first few parts of this series (first, second, and third), I introduced the “reduce” function, and showed how it can be used in a number of ways. However, in all of the examples we have seen so far, the output from our invocations of “reduce” were integers or strings. If we reduce with…
This is the third installment of my “reduce” series of blog posts. For the first, see here, and for the second, see here. If you have been reading this series, then you know that “reduce” can be used to sum numbers, or to calculate scores. In that sense, “reduce” justifies its name; we’re invoking a…
This is the second installment of my series of blog posts on the “reduce” function/method. For an introduction, see here. I love to play Scrabble — or more commonly nowadays, I play Words with Friends on my phone. (I often say that the game should instead be called, “Words with people who used to be your…
One of the notable things about MIT’s computer science curriculum, at least back when I was studying there, was that you didn’t learn any “practical” programming languages. Our work was all done in either Scheme (a dialect of Lisp) or in CLU (an early object-oriented language). I can’t say that I have too many memories,…
It has been many years since Python developers were really supposed to worry about new-style vs. old-style classes. There is only one style (new) in Python 3.x, and even in Python 2.x, old-style classes have not been recommended for many years. Nevertheless, I mention old-style classes in my Python courses, mostly so that participants will…
When I teach a Ruby or Python class, I always begin by going through the various data types. My students are typically experienced programmers in Java, C++, or C#, and so it no longer surprises me when I begin to describe numbers, and someone asks, “How many bits is an integer?” My answer used to…
You can learn more about the class here. Or contact me as “reuvenlerner” on Skype, or via e-mail at reuven@lerner.co.il, to see if it’s right for you!
I have been consulting, developing, and offering training classes in both Ruby and Python for a number of years now — more than 15 years in Python, and more than 7 years in Ruby. Inevitably, when someone from one of my courses hears that I use more than one language, they ask me, “So, which…