Category: Ruby

  • Another free regexp Q&A webinar!

    The last Webinar I did, with Q&A about regular expressions, was great fun — so much, that I’ve decided to do another one. So, if you have questions (big or little) about regular expressions in Python, Ruby, JavaScript, and/or PostgreSQL, sign up for this free Webinar on Monday, April 11th: https://www.crowdcast.io/e/regexpqa2 If you already have…

    Read more

  • Yes, you can master regular expressions!

    Announcing: My new book, “Practice Makes Regexp,” with 50 exercises meant to help you learn and master regular expressions. With explanations and code in Python, Ruby, JavaScript, and PostgreSQL. I spend most of my time nowadays going to high-tech companies and training programmers in new languages and techniques. Actually, many of the things I teach…

    Read more

  • Shark Tank increased our traffic by 1000x. Here’s how we handled it.

    More than five years ago, I started work to with a small company with a simple idea. Rent Like a Champion was founded by alumni of the University of Notre Dame, which has a very strong culture of college football games. (Note to my non-American readers: We’re talking here about American football, rather than “real”…

    Read more

  • Summary of my “reduce” series

    I teach Ruby and Python to a lot of people — in formal courses, and in one-on-one pairing sessions, both online and in person.  I’ve found that for many people, the whole notion of functional programming seems strange and difficult, as well as something of a waste of time.  After all, if you have objects,…

    Read more

  • Implementing “filter” with “reduce”, in Ruby and Python

    We’re nearly at the end of my tour of the “reduce” function in Ruby and Python.  Just as I showed in the previous installment how we can implement the “map” function using “reduce”, I want to show how we can implement another functional-programming standard, “filter”, using “reduce” as well.  As before, I’ll show examples in…

    Read more

  • Implementing “map” with “reduce”, in Ruby and Python

    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…

    Read more

  • Creating Ruby hashes with “reduce”

    In yesterday’s post, I showed how we can use Python’s “reduce” function to create a dictionary.  Ruby, of course, also has dictionaries, but calls them “hashes.”  In this posting, I’m going to show how we can create a hash in Ruby when iterating over an enumerable.  In so doing, we’ll see how we can use…

    Read more

  • Creating collections with “reduce”

    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…

    Read more

  • Implementing “min” and “max” with “reduce”

    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…

    Read more

  • Calculating Scrabble scores with “reduce”

    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…

    Read more