From b27da2a93cc42afcf16ab539dc7aa1a84d12ee8c Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Sun, 15 Nov 2020 08:47:32 +0100
Subject: Rename Perl 6 to Raku
---
lib/Hash/Merge.pm6 | 78 ------------------------------------------
lib/Hash/Merge.rakumod | 78 ++++++++++++++++++++++++++++++++++++++++++
lib/Hash/Merge/Augment.pm6 | 33 ------------------
lib/Hash/Merge/Augment.rakumod | 33 ++++++++++++++++++
4 files changed, 111 insertions(+), 111 deletions(-)
delete mode 100644 lib/Hash/Merge.pm6
create mode 100644 lib/Hash/Merge.rakumod
delete mode 100644 lib/Hash/Merge/Augment.pm6
create mode 100644 lib/Hash/Merge/Augment.rakumod
(limited to 'lib')
diff --git a/lib/Hash/Merge.pm6 b/lib/Hash/Merge.pm6
deleted file mode 100644
index 8f41c07..0000000
--- a/lib/Hash/Merge.pm6
+++ /dev/null
@@ -1,78 +0,0 @@
-#! /usr/bin/env false
-
-use v6.d;
-
-unit module Hash::Merge;
-
-#| Merge any number of Hashes together.
-sub merge-hashes (
- #| Any number of Hashes to merge together.
- *@hashes,
-
- --> Hash
-) is export {
- my %result = @hashes.shift;
-
- # Nothing to do if we only got 1 argument
- return %result unless @hashes.elems;
-
- for ^@hashes.elems {
- %result = merge-hash(%result, @hashes.shift);
- }
-
- %result;
-}
-
-#| Merge two hashes together.
-sub merge-hash (
- #| The original Hash to merge the second Hash into.
- %first,
-
- #| The second hash, which will be merged into the first Hash.
- %second,
-
- #| Boolean to set whether Associative objects should be merged on their
- #| own. When set to False, Associative objects in %second will
- #| overwrite those from %first.
- Bool:D :$deep = True,
-
- #| Boolean to set whether Positional objects should be appended. When
- #| set to False, Positional objects in %second will overwrite those
- #| from %first.
- Bool:D :$positional-append = True,
-
- --> Hash
-) is export {
- my %result = %first;
-
- for %second.keys -> $key {
- # If the key doesn't exist yet in %first, it can be inserted without worry.
- if (%first{$key}:!exists) {
- %result{$key} = %second{$key};
- next;
- }
-
- given (%first{$key}) {
- # Associative objects need to be merged deeply.
- when Associative {
- %result{$key} = $deep
- ?? merge-hash(%first{$key}, %second{$key}, :$deep, :$positional-append)
- !! %second{$key}
- }
- # Positional objects can be merged or overwritten depending on $append-array.
- when Positional {
- %result{$key} = $positional-append
- ?? (|%first{$key}, |%second{$key})
- !! %second{$key}
- }
- # Anything else will just overwrite.
- default {
- %result{$key} = %second{$key};
- }
- }
- }
-
- %result;
-}
-
-# vim: ft=perl6 ts=4 sw=4 et
diff --git a/lib/Hash/Merge.rakumod b/lib/Hash/Merge.rakumod
new file mode 100644
index 0000000..5d496a4
--- /dev/null
+++ b/lib/Hash/Merge.rakumod
@@ -0,0 +1,78 @@
+#! /usr/bin/env false
+
+use v6.d;
+
+unit module Hash::Merge;
+
+#| Merge any number of Hashes together.
+sub merge-hashes (
+ #| Any number of Hashes to merge together.
+ *@hashes,
+
+ --> Hash
+) is export {
+ my %result = @hashes.shift;
+
+ # Nothing to do if we only got 1 argument
+ return %result unless @hashes.elems;
+
+ for ^@hashes.elems {
+ %result = merge-hash(%result, @hashes.shift);
+ }
+
+ %result;
+}
+
+#| Merge two hashes together.
+sub merge-hash (
+ #| The original Hash to merge the second Hash into.
+ %first,
+
+ #| The second hash, which will be merged into the first Hash.
+ %second,
+
+ #| Boolean to set whether Associative objects should be merged on their
+ #| own. When set to False, Associative objects in %second will
+ #| overwrite those from %first.
+ Bool:D :$deep = True,
+
+ #| Boolean to set whether Positional objects should be appended. When
+ #| set to False, Positional objects in %second will overwrite those
+ #| from %first.
+ Bool:D :$positional-append = True,
+
+ --> Hash
+) is export {
+ my %result = %first;
+
+ for %second.keys -> $key {
+ # If the key doesn't exist yet in %first, it can be inserted without worry.
+ if (%first{$key}:!exists) {
+ %result{$key} = %second{$key};
+ next;
+ }
+
+ given (%first{$key}) {
+ # Associative objects need to be merged deeply.
+ when Associative {
+ %result{$key} = $deep
+ ?? merge-hash(%first{$key}, %second{$key}, :$deep, :$positional-append)
+ !! %second{$key}
+ }
+ # Positional objects can be merged or overwritten depending on $append-array.
+ when Positional {
+ %result{$key} = $positional-append
+ ?? (|%first{$key}, |%second{$key})
+ !! %second{$key}
+ }
+ # Anything else will just overwrite.
+ default {
+ %result{$key} = %second{$key};
+ }
+ }
+ }
+
+ %result;
+}
+
+# vim: ft=raku ts=4 sw=4 et
diff --git a/lib/Hash/Merge/Augment.pm6 b/lib/Hash/Merge/Augment.pm6
deleted file mode 100644
index 7c03a9e..0000000
--- a/lib/Hash/Merge/Augment.pm6
+++ /dev/null
@@ -1,33 +0,0 @@
-#! /usr/bin/env false
-
-use v6.c;
-use MONKEY-TYPING;
-
-use Hash::Merge;
-
-# Don't use precompilation in order to not conflict with other MONKEY-TYPING
-# modules.
-no precompilation;
-
-augment class Hash {
- method merge (
- Hash:D:
-
- #| The Hash to merge into this one.
- %hash,
-
- #| Boolean to set whether Associative objects should be merged on their
- #| own. When set to False, Associative objects in %second will
- #| overwrite those from %first.
- Bool:D :$deep = True,
-
- #| Boolean to set whether Positional objects should be appended. When
- #| set to False, Positional objects in %second will overwrite those
- #| from %first.
- Bool:D :$positional-append = True,
- ) {
- self = merge-hash(self, %hash, :$deep, :$positional-append);
- }
-}
-
-# vim: ft=perl6 ts=4 sw=4 et
diff --git a/lib/Hash/Merge/Augment.rakumod b/lib/Hash/Merge/Augment.rakumod
new file mode 100644
index 0000000..e719dc1
--- /dev/null
+++ b/lib/Hash/Merge/Augment.rakumod
@@ -0,0 +1,33 @@
+#! /usr/bin/env false
+
+use v6.d;
+use MONKEY-TYPING;
+
+use Hash::Merge;
+
+# Don't use precompilation in order to not conflict with other MONKEY-TYPING
+# modules.
+no precompilation;
+
+augment class Hash {
+ method merge (
+ Hash:D:
+
+ #| The Hash to merge into this one.
+ %hash,
+
+ #| Boolean to set whether Associative objects should be merged on their
+ #| own. When set to False, Associative objects in %second will
+ #| overwrite those from %first.
+ Bool:D :$deep = True,
+
+ #| Boolean to set whether Positional objects should be appended. When
+ #| set to False, Positional objects in %second will overwrite those
+ #| from %first.
+ Bool:D :$positional-append = True,
+ ) {
+ self = merge-hash(self, %hash, :$deep, :$positional-append);
+ }
+}
+
+# vim: ft=raku ts=4 sw=4 et
--
cgit v1.1