3 ms·
I've been very curious about Perl6's gradual typing[1] which, as I understand it, draws a lot from Haskell's type system but in an optional manner. subset
by athenot 10y ago
I've been very curious about Perl6's gradual typing[1] which, as I understand it, draws a lot from Haskell's type system but in an optional manner.
subset NonNegativeInt of Int where * >= 0;
sub fib(NonNegativeInt $nth) {
given $nth {
when 0 { 0 }
when 1 { 1 }
default { fib($nth-1) + fib($nth-2) }
}
}
[1] http://blogs.perl.org/users/ovid/2015/02/avoid-a-common-software-bug-by-using-perl-6.html http://blogs.perl.org/users/ovid/2015/02/avoid-a-common-soft...