package core;
use strict;
use warnings FATAL => qw(all);
+use List::Util qw(pairmap);
use Time::HiRes qw(time);
use readline;
use types qw(_sequential_Q _equal_Q _clone $nil $true $false
_nil_Q _true_Q _false_Q
_number_Q _symbol _symbol_Q _string_Q _keyword _keyword_Q _list_Q _vector_Q _sub_Q _function_Q
- _hash_map _hash_map_Q _assoc_BANG _atom_Q);
+ _hash_map _hash_map_Q _atom_Q);
use reader qw(read_str);
use printer qw(_pr_str);
sub assoc {
my $src_hsh = shift;
- my $new_hsh = { %$src_hsh };
- return _assoc_BANG($new_hsh, @_);
+ return HashMap->new( { %$src_hsh, pairmap { $$a => $b } @_ } );
}
sub dissoc {
our @EXPORT_OK = qw(_sequential_Q _equal_Q _clone
$nil $true $false _nil_Q _true_Q _false_Q
_number_Q _symbol _symbol_Q _string_Q _keyword _keyword_Q _list_Q _vector_Q _sub_Q _function_Q
- _hash_map _hash_map_Q _assoc_BANG _atom_Q);
-use List::Util qw(pairs);
+ _hash_map _hash_map_Q _atom_Q);
+use List::Util qw(pairs pairmap);
use Data::Dumper;
sub get { no overloading '%{}'; $_[0]->{val}->{$_[1]}; }
}
-sub _hash_map {
- my $hsh = {};
- return _assoc_BANG($hsh, @_);
-}
-
-sub _assoc_BANG {
- my $hsh = shift;
- foreach my $pair (pairs @_) {
- my ($k, $v) = @$pair;
- $hsh->{$$k} = $v;
- }
- return HashMap->new($hsh);
-}
+sub _hash_map { HashMap->new( { pairmap { $$a => $b } @_ } ) }
sub _hash_map_Q { $_[0]->isa('HashMap') }