Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make .list, .flat, .eager & .hash type object aware.
If called on just a type object, they will all return an empty list/hash.
  • Loading branch information
lizmat committed Jul 24, 2013
1 parent 340fc12 commit d12ecc5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/core/Any.pm
Expand Up @@ -13,10 +13,24 @@ my class Any {

# primitives
method infinite() { Nil }
method list() { nqp::p6list(nqp::list(self), List, Mu) }
method flat() { nqp::p6list(nqp::list(self), List, Bool::True) }
method eager() { nqp::p6list(nqp::list(self), List, Bool::True).eager }
method hash() { my % = self }
method list() {
nqp::p6list(
self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Mu
);
}
method flat() {
nqp::p6list(
self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Bool::True
);
}
method eager() {
nqp::p6list(
self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Bool::True
).eager;
}
method hash() {
my % = self.DEFINITE ?? self !! ();
}

# derived from .list
method elems() { self.list.elems }
Expand Down

0 comments on commit d12ecc5

Please sign in to comment.