Archive for Languages

nyc.rb In The House!

Last night’s meeting was a smashing success. We had our largest turnout ever with what I think was 28 people. My presentation went very well, with only a few minor corrections coming from the illustrious David Black. For those of you following along via the web, I’ve updated the copy of the presentation available here to reflect those corrections. Moving past my accomplishments, Zed Shaw gave a highly informative presentation on the use of statistics to gauge performance. Also, Greg Brown talked about his reporting library Ruport, which looks very interesting. Needless to say, the meeting was amazing, and I hope to see you at the next one.


Getting to Done

Tonight’s presentation on higher order procedures is now listed on the Presentations page to your right. I’ll be adding some practice exercises later, but feel free to check out what I have already.


Objects from Scratch

Look ma, I made my own object! It doesn’t handle state that well, but at least it can be passed messages and told to do things.

def make_number(x)
  lambda do |op, *y|
    if op == '+'
      make_number(x + y[0])
    elsif op == '-'
      make_number(x - y[0])
    elsif op == 'val'

my_num = make_number(5)         => <#Proc>'+', 7).call('val') => 12

In case you can’t tell, this object creation makes use of higher order procedures. The make number procedure returns the anonymous procedure created by lambda. This form of object creation is not terribly practical, but it sure is cool.


How to be Smart

So after reading this blog for a little while, you’re probably wondering “How can I be as smart as this Trotter fella?” Well, let me clue you in on the secret of my skillz. I’m reading Structure and Interpretation of Computer Programs. It may be old, but wisdom never spoils. Read it and get smart.

Comments (3)


Time to play with synonyms. Let me know which versions you like better.

result = 0
0.upto(arr.length) do |i|
  result += arr[i]


arr.inject{|x,y| x + y}

How about this one?

0.upto(arr.length) do |i|
  arr[i] = 10+arr[i]

or! {|x| 10 + x}

Higher-order procedures are h0t!

Comments (3)

Blocks and Closures in Ruby

So, I’ve finally started doing actual research for this presentation beyond asking, “What do I already know?” First stop on the research train? Blocks and Closures in Ruby over at Artima. It’s an interview with Matz (the creator of Ruby for those of you not in the know) discussing how cool it is that Ruby supports blocks and closures. Read on to get an abrievated version of what goes on in the article.

Read the rest of this entry »



Remember how I said that we would be seeing a lot more about higher-order procedures on this site? Well, I’m giving a talk on using them in Ruby this coming Tuesday. All of my research will be posted here along with the final presentation. So get ready to read, because there’s going to be a lot of information coming at you.



After spending a little time with scheme’s concept of quotation, I must say that I really enjoy it. What makes quotation very nice is that it allows you to express new language constructs in the syntax of the original language. For instance, (+ x y) and ‘(+ x y) share the same syntax. The only difference is that the quotation in the second case prevents the expression from actually being evaluated.

I can already hear you screaming “Wait! What’s the difference between ‘(+ x y) and “(+ x y)”?!?!” Well my friends, the beauty of quotation is that you can use normal scheme’s normal list manipulation to parse ‘(+ x y). There is no need to go searching through strings to determine what is where. Instead, it’s all just a bunch of car’s and cdr’s.


« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »