HCoop
/
jackhill
/
mal.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
91a8ef0
)
perl: Fold some simple core functions into %core::ns.
author
Ben Harris
<bjh21@bjh21.me.uk>
Fri, 26 Jul 2019 21:01:36 +0000
(22:01 +0100)
committer
Ben Harris
<bjh21@bjh21.me.uk>
Fri, 26 Jul 2019 22:54:09 +0000
(23:54 +0100)
perl/core.pm
patch
|
blob
|
blame
|
history
diff --git
a/perl/core.pm
b/perl/core.pm
index
7e0c96d
..
2ed1d85
100644
(file)
--- a/
perl/core.pm
+++ b/
perl/core.pm
@@
-88,10
+88,6
@@
sub cons {
List->new([$a, @$b]);
}
List->new([$a, @$b]);
}
-sub concat {
- List->new([map @$_, @_]);
-}
-
sub nth {
my ($seq,$i) = @_;
return $seq->[$i] || die "nth: index out of bounds";
sub nth {
my ($seq,$i) = @_;
return $seq->[$i] || die "nth: index out of bounds";
@@
-102,12
+98,6
@@
sub first {
return $seq->[0] || $nil;
}
return $seq->[0] || $nil;
}
-sub rest { return $_[0]->rest(); }
-
-sub count {
- return Integer->new(scalar(@{$_[0]}))
-}
-
sub apply {
my $f = shift;
my $more_args = pop;
sub apply {
my $f = shift;
my $more_args = pop;
@@
-158,10
+148,6
@@
sub with_meta {
return $new_obj;
}
return $new_obj;
}
-sub meta {
- return $_[0]->meta;
-}
-
# Atom functions
sub swap_BANG {
# Atom functions
sub swap_BANG {
@@
-220,18
+206,18
@@
sub swap_BANG {
'sequential?' => sub { _sequential_Q($_[0]) ? $true : $false },
'nth' => sub { nth($_[0], ${$_[1]}) },
'first' => \&first,
'sequential?' => sub { _sequential_Q($_[0]) ? $true : $false },
'nth' => sub { nth($_[0], ${$_[1]}) },
'first' => \&first,
- 'rest' =>
\&rest
,
+ 'rest' =>
sub { $_[0]->rest() }
,
'cons' => \&cons,
'cons' => \&cons,
- 'concat' =>
\&concat
,
+ 'concat' =>
sub { List->new([map @$_, @_]) }
,
'empty?' => sub { @{$_[0]} ? $false : $true },
'empty?' => sub { @{$_[0]} ? $false : $true },
- 'count' =>
\&count
,
+ 'count' =>
sub { Integer->new(scalar(@{$_[0]})) }
,
'apply' => \&apply,
'map' => \&mal_map,
'conj' => \&conj,
'seq' => \&seq,
'with-meta' => \&with_meta,
'apply' => \&apply,
'map' => \&mal_map,
'conj' => \&conj,
'seq' => \&seq,
'with-meta' => \&with_meta,
- 'meta' =>
\&meta
,
+ 'meta' =>
sub { $_[0]->meta }
,
'atom' => sub { Atom->new($_[0]) },
'atom?' => sub { _atom_Q($_[0]) ? $true : $false },
'deref' => sub { ${$_[0]} },
'atom' => sub { Atom->new($_[0]) },
'atom?' => sub { _atom_Q($_[0]) ? $true : $false },
'deref' => sub { ${$_[0]} },