Name : perl-Tie-LazyList
| |
Version : 0.05
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp156.7.1
| Date : 2024-07-03 19:15:47
|
Group : Development/Libraries/Perl
| Source RPM : perl-Tie-LazyList-0.05-lp156.7.1.src.rpm
|
Size : 0.02 MB
| |
Packager : https://www_suse_com/
| |
Summary : Perl extension for lazy lists growing on demand
|
Description :
\'Tie::LazyList\' allows you to create *lazy lists* ( \"infinite lists, whose tail remain unevaluated\", Watt ) growing on demand with user-defined generation function.
What you have is a usual Perl array whose elements are generated by some function and which may be accessed by \'$arr[x]\' as any other, but actually grows _under the hood_ if the element you\'re accessing isn\'t generated yet. This way, the amount of memory wasted for the array is no more ( and no less, unfortunately ) then you need. Think about it as dynamically growing factorials ( Fibonacci numbers, arithmetic progression .. ) table which you can access for any element without need to explicitly build and maintain it.
All you need to specify is the initial list elements, generation function and .. that\'s it, actually - go and work with it ! See the example above - I think, they demonstrate the simplicity.
So, here are the rules : you create the new lazy list by
\'tie AATTarray, \'Tie::LazyList\'\', \'list init\', \'generation function\'
or
\'tie AATTarray, \'Tie::LazyList\',\' \'ARRAY reference\'
where
* \'list init\'
Initial elements of your list. It may be a single scalar variable ( number, usually ) or an array reference ( if you\'d like to initialize more then one element ). Examples : \'1\' or \'2\' or \'[ 1, 2, 3 ]\'
* \'generation function\'
Reference to the function which will be called to generate new list elements. When called it\'ll be passed the following parameters :
* *
reference to the array filled from index \'0\' upto \'n-1\'
* *
\'n\' - index of the element to generate
The function should return the value of the \'n\'-th array element.
In order to make our life a bit easier there is a number of, what I call, code abbreviations. It means that \'generation function\' may be not the code reference, but something much simpler - string, having one of the predefined values. Those values tell the module which \'generation function\' to use and they are :
* APROG
Means *a*rithmetic *prog*ression, \'list init\' should contain at least two elements in order to calculate progression\'s factor.
* GPROG
Means *g*eometric *prog*ression, \'list init\' has the same restriction as in APROG.
* APROG_SUM
Means *a*rithmetic *prog*ression\'s *sum*mary, \'list init\' should contain, again, at least two elements, but of the _original progression_ !
* GPROG_SUM
Means *g*eometric *prog*ression\'s *sum*mary, \'list init\' has the same restriction as in APROG_SUM.
* FIBON
Means *Fibon*acci numbers, \'list init\' should contain at least two elements ( \'[ 0, 1 ]\', as you know )
* FACT
Means *fact*orials, \'list init\' should contain one element at least ( \'1\', as you know )
* POW
Means *pow*er - arising \'x\' to any power, \'list init\' should contain only numbers.
* ???
I\'m not a mathematician .. If you have more ideas, send them to genieAATTcpan.org !
* \'ARRAY reference\'
Reference to another array, already tied to \'Tie::LazyList\'.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/15.6/noarch |