[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] fun with numbers



On Tue, Jul 18, 2000 at 11:48:48PM -0400, Michael G Schwern wrote:
>
>     use Tie::Math qw(f X Y);
>     
>     my %pascal;
>     tie %pascal, 'Tie::Math', sub { 
>                                   if( X <= Y and Y > 0 and X > 0 ) {
>                                       f(X,Y) = f(X-1,Y-1) + f(X,Y-1);
>                                   }
>                                   else {
>                                       f(X,Y) = 0;
>                                   }
>                               },
>                               sub { 
>                                   f(1,1) = 1;  f(1,2) = 1;  f(2,2) = 1; 
>                               };
>     
> 
> Unfortunately, the if/else statement to bound the equation bothers me
> deeply, since I intended Tie::Math to be familiar to mathematical
> types and avoid any programming logic.  I'm working on a bounding
> conditions so one can say something natural.

    sub {
        f (X, Y) = f (X-1, Y-1) + f (X, Y-1) if X <= Y and Y >  0 and X >  0;
        f (X, Y) = 0                         if X >  Y or  Y <= 0 or  X <= 0;
    }


Abigail

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe