in reply to Adding 2 + 2
Lambda calculus! But it doesn't have integers (or any data types for that matter), you say? Sure it does, it has Church numerals!
Yeah, at some point we have to convert the Church numeral to something that Perl can print.. but you get the idea.my $two = sub { my($f,$x) = @_; $f->($f->($x)); }; sub add { my($m,$n) = @_; sub { my($f,$x) = @_; $m->($f, $n->($f, $x)) }; } sub decode { my($n) = @_; $n->( sub{$_[0]+1}, 0 ); } print decode( add($two, $two) ), $/;
blokhead
|
---|
In Section
Cool Uses for Perl