Perl6-Pugs
view release on metacpan or search on metacpan
ext/Perl6-Container-Array/lib/Perl6/Container/Array.pm view on Meta::CPAN
use v6-alpha;
=begin ChangeLog
2005-08-10
* New methods Array.flatten(), is_lazy()
- Lazy Array changes to normal Array if all elements are known;
- pushing a lazy list into a normal array turns the array into a lazy array
* New method: Array.is_infinite()
* Renamed methods: Array.new() -> Array.from_list(); Array.splat() -> Array.to_list
* New List methods: is_contiguous(), to_str(), clone(), to_ref(), to_bit(), to_num()
* New List hooks: is_contiguous( $code ), stringify( $code )
* Started syncing with Perl5 version
* Removed class Lazy::Range
* Lowercase methods fetch(), store()
* Removed redundant methods next(), previous()
2005-08-09
* Renamed Lazy::List to Perl6::Value::List
* Renamed Array::Lazy to Perl6::Container::Array
* Removed fetch_slice() because it is non-standard.
2005-08-08
* New lazy array methods: FETCH(), STORE(), fetch_slice().
slice accepts a lazy list or lazy array as argument!
* elems() actually works
* more or less fixed Lazy::List::reverse() inheritance
* Lazy::CoroList is gone
* Lazy list methods (grep, map, ...) moved from Array::Lazy to
Lazy::List. These methods can be accessed from an array
by doing a 'splat()' first.
Array::Lazy::reverse() is still supported.
2005-08-07
* Lazy Range supports 'a'..Inf
* New lazy array methods: splat(), elems(), uniq(), end(),
next(), previous(), kv(), keys(), values(), zip()
* Code rewritten to use coroutines instead of states
* New class Lazy::CoroList - takes a coroutine (or two,
for shift and pop support) and creates a Lazy List, that
can be used to create a Lazy Array.
* Removed internal class Lazy::Generator
2005-08-06
* new lazy methods reverse(), grep(), map()
* Array::Lazy supports multi-dimensional Lazy Array
* new class 'Lazy::List'
* lazy List / Array of junctions is tested
* removed 'Iter' class; renamed 'Iter::Range' to 'Lazy::Range'
=cut
# TODO - test splice() with parameter 'Array @list'
# TODO - add lazy/strict tests
# TODO - 'dim'
# TODO - sync with Perl5 version of Array
# TODO - exists(), delete() - S29
# TODO - preprocessing, indexing, etc - lazily
# TODO - add support for sparse arrays
# - what happens when $a.FETCH(100000000)
# implement this error message (from PIR.pm)
# if $off > $size {
# warn "splice() offset past end of array\n";
# $off = $size;
# }
# Things that will be solved by the compiler:
# - fetch slice / store slice - @a[5,7]=('x','y')
# - keys/kv/pairs/values with indexes (S29)
use Perl6::Value::List;
# This class should not inherit from Perl6::Value::List, because this would
# cause multi-dimensional arrays to be flattened.
class Perl6::Container::Array-0.01
{
has Array @.items;
method from_list ( $class: *@items ) {
$class.new( items => [@items] );
}
method _shift_n (Int $length ) returns List {
my @ret;
my @tmp = @.items;
if $length == Inf {
@.items = ();
return @tmp;
}
while @tmp {
last if @ret >= $length;
unless @tmp[0].isa(Perl6::Value::List) {
&*push( @ret: @tmp.shift );
( run in 0.327 second using v1.01-cache-2.11-cpan-e93a5daba3e )