HOI-Comprehensions version 0.01
===============================

The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.

A README file is required for CPAN modules since CPAN extracts the
README file from a module distribution so that people browsing the
archive can use it get an idea of the modules uses. It is usually a
good idea to provide version information here so that people can
decide whether fixes for the module are worth downloading.

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

    Alias >= 2.32

NAME

HOI::Comprehensions - Higher-Order Imperative "Re"features in Perl: List Comprehensions

SYNOPSIS

  my $list = comp( sub { $x + $y + $z }, x => [ 1, 2, 3 ], y => [ 4, 5, 6 ], z => sub { ( 1, 1 ) } )->( sub { $x > 1 } );

  my ($elt, $done);
  do {
      ($elt, $done) = <$list>;
      print "$elt ";
  } while (not $done);
  print "\n";

DESCRIPTION

HOI::Comprehensions offers lazy-evaluated list comprehensions with limited support to 
generators of an infinite list. It works as if evaluating multi-level loops lazily.

Currently, the generators are handled in sequence of the argument list offered by the user.
As a result of such implementation, a list
    { (x, y) | x is natural number, y belongs to { 0, 1 }, x is odd }
may be evaluated incorrectly. To avoid such situation, make sure finite generators 
are subsequent to all the infinite ones.

FUNCTIONS

comp($@)->(@)

For creating a list comprehension object. The formula for computing the elements of
the list is given as a subroutine, following by the generators, in form of name => arrayref
or name => subroutine. Comp returns a function which takes all guards in form of subroutines.

A hashref which holds generator variables as its keys and value of those variables as
its values is passed to the formula subroutine. However, it is recommended to use such
variables directly instead of dereference the hashref.

METHODS

get_list

Get the list member of a list comprehension object. It returns a arrayref which holds
the actual list evaluated so far.

is_over

Returns a boolean which tells if the evaluation of the list is over.

get_member($)

Get a member of a list comprehension object by name.
A list comprehension object is actually a blessed hashref.

OPERATORS

<>

List evaluation iterator. Returns the "next" element generated in the sequence in the 
situation of eager evaluation, and a flag telling whether the evaluation is done.

+

List indexing operator. Takes an integer as the index and a list comprehension object.
The operator returns an arrayref [ $elt, $done ], where $elt is the element at the given
index and $done is a flag telling whether the evaluation is done.

COPYRIGHT AND LICENCE

Copyright (C) 2014 by withering

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.20.0 or,
at your option, any later version of Perl 5 you may have available.