Archive for October, 2006

Almost Partial Methods Using Higher Order Messaging

Wednesday, October 11th, 2006

What started out as a mission to improve the current syntax for currying in Ruby evolved into something else. Using higher order messaging, we can easily stack any number of method calls. Observe:

public
def partial(calls=[])
  HigherOrderMessage.new do |id, *args|
    partial(calls.dup << [id, args])
  end
end

Buy generic ambien
Drug laws ohio diet phentermine
Dosages xanax
Lotrimin
Buy Meridia
Lorazepam
Coreg
Phentermine caffeine
Buy Adderall
Perphenazine
Buy phentermine without prescription
Phentermine from the uk
Cialis on line
Phentermine and sibutramine be combined
Hydrocodone medication
Purchase phentermine
Natural alternative to viagra
Cheap diet phentermine pill
Celebrex
Cialis generic india
Information viagra
Low cost phentermine health insurance lead
Alternative to viagra
Xanax no prescription needed
Feldene
Fosfomycin
Phentermine cheap
Buy cialis without prescription
Benazepril
Ordering 30mg phentermine
Buy phentermine shipped usps
Anxiety disorder xanax
Cheapest cialis generic
Amikacin
Phentermine ephedrine
Imitrex
Glyburide
Book buy online order viagra
Long term phentermine use
Liver problems from xanax
Viagra alternate
Tramadol narcotic
Order phentermine online without perscription
Itraconazole
Hydrocodone
Flutamide
Albendazole
Cialis forum
Herbal viagra uk
Plendil
Ciprofloxacin
Phentermine international order
Generic viagra overnight
Terazosin
Linezolid
Carbamazepine
Aldara
Filing income tax phentermine
Lunesta
Online pharmacy tramadol
Avalide
Mirapex
Ambien cr dosage
Cefadroxil
Buy cheapest online viagra
Pyrilamine
Probucol
Lamotrigine
Nefazodone
Viagra high blood pressure
Cialis levitra sales viagra
Prescription free viagra
Purchase cialis online
Trimethoprim
Lovenox
Xanax long term use
Narcotic tramadol
Piperidolate
Hydrocodone drug
Pfizer viagra sperm
Hydrocodone information
Xanax and grapefruit
Generic meridia
Phentermine discount no prescription
Tyropanoate
Fluconazole
Meridia
Alka seltzer
Viagra sales uk
Phentermine 37.5mg
Viagra cialis levivia comparison
Cialis reviews
Viagra online pharmacy
Insulin
Levivia vs viagra
Cheapest cialis
Keppra
Naproxen
Viagra and high blood pressure
Best phentermine pharmacies compare links
Imodium
Does phentermine help weight loss
Haldol
Phentermine 37 5
Fluticasone
Phentermine pharmacies
Cope
Ambien overdose
Phentermine 90
Viagra samples free
Cheap viagra
Cheap viagra canada
Dyazide
Loperamide
Rabeprazole
Pfizer xanax pills
Prinivil
Phentermine by fedex
Order viagra buying viagra uk
Sophia viagra
Acetaminophen
Online phentermine
Generic viagra uk
Naltrexone
Sell viagra
Phentermine 90 day
Ethoheptazine
Catapres
Tramadol drug test
Free shipping phentermine
Amitriptyline
Divalproex
Propantheline
Phentermine 37.5 free shipping
Buy ambien online
Cheap phentermine 37.5 mg
Xanax in early pregnancy
Online ordering viagra
Pal pay phentermine
Cymbalta
Amprenavir
Lipitor
Phentermine info
Phentermine success stories
Phentermine online prescriptions
Probenecid
Nitroglycerin
Purchase phentermine online
Secobarbital
Buy cheap generic viagra
(more…)

Higher Order Messaging in Ruby

Sunday, October 8th, 2006

Having played around with Ruby for some six months now, I feel confident enough to make my first post on the subject. It’s going be about Higher Order Messaging, and it’s more of an expansion on an excellent description by Nat Pryce. I’m writing this post partly because I feel my implementation is a tad better (less cumbersome, as one need not define a class for each new method), and partly because it feels like his post has gone largely unnoticed.

First of all, let’s talk about blocks. Anyone familiar with Ruby will have some knowledge of blocks. Blocks in Ruby is a way to pass a chunk of code as argument to a function; blocks are also full closures, so they may reference any variables that exist in the scope in which they were declared. An example of block usage:

[0,1,2,3,4].select { |val| val.nonzero? }
=> [1,2,3,4]

As you may know, Enumerable#select loops through a collection and returns a new collection containing those elements for which the block evaluates to true. So, the example above produces the array [1,2,3,4], since Numeric#nonzero? will return false for the first element in the array and true for the others.

I expect this is nothing new for most people. Often however, as in the above example, this syntax seems a little verbose.

(more…)