gitpan / tie-math Goto Github PK
View Code? Open in Web Editor NEWRead-only release history for Tie-Math
Home Page: http://metacpan.org/release/Tie-Math
Read-only release history for Tie-Math
Home Page: http://metacpan.org/release/Tie-Math
NAME Tie::Math - Hashes which represent mathematical functions. SYNOPSIS use Tie::Math; tie %fibo, 'Tie::Math', sub { f(n) = f(n-1) + f(n-2) }, sub { f(0) = 0; f(1) = 1 }; # Calculate and print the fifth fibonacci number print $fibo{5}; DESCRIPTION Defines hashes which represent mathematical functions, such as the fibonacci sequence, factorials, etc... Functions can be expressed in a manner which a math or physics student might find a bit more familiar. It also automatically employs memoization. Multi-variable functions are supported. f() is simply passed two variables (f(X,Y) for instance) and the hash is accessed in the same way ($func{3,-4}). tie tie %func, 'Tie::Math', \&function; tie %func, 'Tie::Math', \&function, \&initialization; &function contains the definition of the mathematical function. Use the f() subroutine and N index provided. So to do a simple exponential function represented by "f(N) = N**2": tie %exp, 'Tie::Math', sub { f(N) = N**2 }; &initialization contains any special cases of the function you need to define. In the fibonacci example in the SYNOPSIS you have to define f(0) = 1 and f(1) = 1; tie %fibo, 'Tie::Math', sub { f(N) = f(N-1) + f(N-2) }, sub { f(0) = 1; f(1) = 1; }; The &initializaion routine is optional. Each calculation is "memoized" so that for each element of the array the calculation is only done once. While the variable N is given by default, A through Z are all available. Simply import them explicitly: # Don't forget to import f() use Tie::Math qw(f X); There's no real difference which variable you use, its just there for your preference. (NOTE: I had to use captial letters to avoid clashing with the y// operator) AUTHOR Michael G Schwern <[email protected]> WHAT IS THIS? This is Tie::Math, a perl module. HOW DO I INSTALL IT? To install this module, cd to the directory that contains this README file and type the following: perl Makefile.PL make make test make install To install this module into a specific directory, do: perl Makefile.PL PREFIX=/name/of/the/directory ...the rest is the same... Please also read the perlmodinstall man page, if available. WHAT ELSE DO I NEED? Perl 5.6.0 and up
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.