News for hackers. Stuff that matters.
Re:Joel Spolsky: Can your programming language do this? by SpookyAction on Saturday April 23, 2011 @10:31PM (#2478147)
"Look! We're passing in a function as an argument. Can your language do this?"

Umm, yes it can....

#!/usr/bin/perl

sub cook_time { ($hours, $min) = @_; $result = "$hours hours and $min minutes\n"; return $result; }

sub animal { $animal = shift; return $animal; }

sub cook_animal { ($get_animal, $get_time) = @_; return "Cook $get_animal for $get_time"; }

print cook_animal(animal(cow),cook_time(5,23));

There are no comments on this comment yet.