summaryrefslogtreecommitdiff
path: root/hybrids.c
diff options
context:
space:
mode:
Diffstat (limited to 'hybrids.c')
-rw-r--r--hybrids.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/hybrids.c b/hybrids.c
index 2ac2a91..da42e62 100644
--- a/hybrids.c
+++ b/hybrids.c
@@ -7,9 +7,9 @@
Rune primhybridnames[] = L"/\\⌿⍀";
fndyad hybridfunctiondefs[] = {
- 0, /* / */
+ fnReplicateLast, /* / */
0, /* \ */
- 0, /* ⌿ */
+ fnReplicateFirst, /* ⌿ */
0, /* ⍀ */
};
@@ -21,6 +21,22 @@ opmonad hybridoperatordefs[] = {
};
/* function definitions */
+Array *
+fnReplicateLast(Array *left, Array *right)
+{
+ return rundfn(L"⍉⍺⌿⍉⍵", nil, nil, left, right);
+}
+
+Array *
+fnReplicateFirst(Array *left, Array *right)
+{
+ Rune *code =
+ L"(0=≢⍴⍵)∧⍺∧.=0: 0⍴⍵ ⋄"
+ L"⍺∧.=0: (((1,¯1+≢⍴⍵)⌿¯1 1)⌿⍴⍵)⍴⍵ ⋄"
+ L"1=×⌿⍴,⍵: ↑⍪⌿(+⌿⍺)⍴⊂⍵ ⋄"
+ L"↑↑⍪⌿⍺ (⍵{e←⊂⍵⌷⍶ ⋄ ⍺>0: ⍺⍴e ⋄ (|⍺)⍴⎕PROTO e})¨⍳≢⍵";
+ return rundfn(code, nil, nil, left, right);
+}
/* operator definitions */
Array *