8 ms·
"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) = @_; $re
by SpookyAction 15y ago
"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));