Skip to content
Permalink
Browse files

Streamline Map/Hash.gist a bit more

  • Loading branch information...
lizmat committed Jan 8, 2019
1 parent f010ef5 commit 225d2f9669f3b1d9e1d2ae668ba430691e664dad
Showing with 11 additions and 13 deletions.
  1. +6 −10 src/core/Hash.pm6
  2. +5 −3 src/core/Map.pm6
@@ -195,16 +195,12 @@ my class Hash { # declared in BOOTSTRAP
}

multi method gist(Hash:D:) {
self.gistseen(self.^name, {
'{' ~
self.sort.map({
state $i = 0;
++$i == 101 ?? '...'
!! $i == 102 ?? last()
!! .gist
}).join(', ')
~ '}'
})
self.gistseen: self.^name, {
'{'
~ self.sort.head(100).map(*.gist).join(', ')
~ (', ...' if self.elems > 100)
~ '}'
}
}

multi method DUMP(Hash:D: :$indent-step = 4, :%ctx) {
@@ -213,9 +213,11 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
}

multi method gist(Map:D: --> Str:D) {
my @pairs = self.sort.head(100).map: *.gist;
@pairs.push("...") if self.elems > 100;
self.^name ~ '.new((' ~ @pairs.join(', ') ~ '))'
self.^name
~ '.new(('
~ self.sort.head(100).map(*.gist).join(', ')
~ (', ...' if self.elems > 100)
~ '))'
}

multi method perl(Map:D \SELF: --> Str:D) {

0 comments on commit 225d2f9

Please sign in to comment.
You can’t perform that action at this time.