package Camila::Seq;

use 5.006;
use strict;
use warnings;

use Camila;
use Data::Dumper;

require Exporter;

our @ISA = qw(Exporter);

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration	use Camila::Seq ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw( );
our $VERSION = '0.01';

# Constructs an empty new sequence as a object
sub new  { return bless([]) }
sub nill { return new()     }

# From values
sub from_values { return bless( [map {$_->repr} @_] ) }

# Typical function cons. Puts element on sequence head
sub cons {
  my ($head,$tail) = @_;
  unshift @{$tail}, $head;
  return $tail;
}

# Typical head function
sub hd {
  my $self = shift;
  return $self->[0];
}

# Typical tail function
sub tl {
  my $self = shift;
  my @array = @$self;
  my @ret = @array[1..$#array];
  return bless(\@ret);
}

sub conc {
  my ($a,$b) = @_;
  my @new = @{$a};
  foreach (@{$b}) {
    push @new, $_;
  }
  return bless(\@new)
}

sub show {
  my $self = shift;
  return "< ".join(" ",map {my $x = Camila::regen($_);
			    $x->show} @{$self})." >";
}
sub repr { return Dumper(shift) }

1;
__END__

=head1 NAME

Camila::Seq - Perl module extension for managing sequences for Camila

=head1 SYNOPSIS

  use Camila::Seq;

  $sequence = Camila::Seq::new();

  $sequence->cons('value');

  $sequence->hd;

  $sequence->tl;

=head1 DESCRIPTION



=head1 AUTHOR

Alberto Simões, E<lt>albie@alfarrabio.di.uminho.ptE<gt>

=head1 SEE ALSO

L<perl>.

=cut
