citizen428.blog()

Try to learn something about everything

Information Overload 2012-09-02

Information Overload 2012-08-26

Remember how I said there probably won’t be an Information Overload this week? Turns out I was wrong :-)

Information Overload 2012-08-19

Note: I’ll probably be too busy this upcoming week, so don’t expect an Information Overload next Sunday.

Information Overload 2012-08-12

Information Overload 2012-08-05

Ruby — Left Section for Infix Operators

Let me admit right away that this is yet another “because I can” type of post with little practical use. With that out of the way, today’s topic is sections of infix operators as known from e.g. Haskell. Here’s an example:

1
2
λ> map (2+) [1..3]
[3,4,5]

As you can see the function to be mapped is specified with the partially applied function (2+) (or (+2) for that matter).

Here’s how we would have to write the same code in Ruby:

1
(1..3).map { |i| i + 2 }

This could also be written in a pointfree way, but alas that would make the code rather hard to understand for less experienced Rubyists:

1
(1..3).map(&2.method(:+))

But because Ruby is as flexible as it is, adding partial application is actually really trivial:

1
2
3
4
5
6
7
class Fixnum
  alias :add :+

  def +(o=nil)
    o ? self.add(o) : lambda { |x| self + x }
  end
end

And now we can do this:

1
(1..3).map(&2.+) #=> [3, 4, 5]

Not too bad I think and rather consistent with Ruby’s overall style. Alas I don’t think we are likely to see partial application on a language level any time soon though…

Information Overload 2012-07-29

Review: Ruby and MongoDB Web Development

Disclaimer: I was one of the technical editors of this book, so I may be biased.

While I haven’t received the book in its final form yet, I’ve read all of it, and I can say that the author does a good job at introducing inexperienced programmers to web development with Ruby and MongoDB.

This is a hands-on book and you’ll get most out of it by following all the exercises and doing them on your own. From getting all the necessary components and installing them, to developing apps with Sinatra and Rails, a lot of ground is covered.

While the author does tackle some more advanced topics, they are clearly not the focus of this book (it’s subtitled “Beginner’s Guide” for a reason) which will leave more experienced developers wanting for more. However, the presented material is well written, chapters build on each other and if you are new to web development with Ruby/RoR and/or MongoDB, this is a good title to get you up to speed in just 300 pages.

If you are a more experienced Ruby developer or are already very familiar with MongoDB, this is probably not the book for you, even though you’ll probably still get something out of it.

Information Overload 2012-07-22

I was busy last week, so this issue of the Information Overload is very short and a bit late.

Information Overload 2012-07-15