Skip to content

Instantly share code, notes, and snippets.

@m-doughty

m-doughty/pure_and_impure.pl Secret

Created Sep 22, 2020
Embed
What would you like to do?
Pure & impure functions
# This is an impure function, calling double will return 2 the first time, then 4, then 8...
my $input = 1;
sub double {
$input = $input * 2;
return $input;
}
# This is a pure function, calling triple(1) will always return 3.
sub triple {
my $n = shift;
return $n * 3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment