summaryrefslogtreecommitdiff
path: root/vere/pkg/noun/jets/c/rsh.c
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
committerpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
commitfcedfddf00b3f994e4f4e40332ac7fc192c63244 (patch)
tree51d38e62c7bdfcc5f9a5e9435fe820c93cfc9a3d /vere/pkg/noun/jets/c/rsh.c
claude is gud
Diffstat (limited to 'vere/pkg/noun/jets/c/rsh.c')
-rw-r--r--vere/pkg/noun/jets/c/rsh.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/vere/pkg/noun/jets/c/rsh.c b/vere/pkg/noun/jets/c/rsh.c
new file mode 100644
index 0000000..6fc8ddf
--- /dev/null
+++ b/vere/pkg/noun/jets/c/rsh.c
@@ -0,0 +1,60 @@
+/// @file
+
+#include "jets/k.h"
+#include "jets/q.h"
+#include "jets/w.h"
+
+#include "noun.h"
+
+u3_noun
+u3qc_rsh(u3_atom a,
+ u3_atom b,
+ u3_atom c)
+{
+ if ( !_(u3a_is_cat(a)) || (a >= 32) ) {
+ return u3m_bail(c3__fail);
+ }
+ else if ( !_(u3a_is_cat(b)) ) {
+ return 0;
+ }
+ else {
+ c3_g a_g = a;
+ c3_w b_w = b;
+ c3_w len_w = u3r_met(a_g, c);
+
+ if ( b_w >= len_w ) {
+ return 0;
+ }
+ else {
+ u3i_slab sab_u;
+ u3i_slab_init(&sab_u, a_g, (len_w - b_w));
+
+ u3r_chop(a_g, b_w, (len_w - b_w), 0, sab_u.buf_w, c);
+
+ return u3i_slab_mint(&sab_u);
+ }
+ }
+}
+
+u3_noun
+u3wc_rsh(u3_noun cor)
+{
+ u3_atom bloq, step;
+ u3_noun a, b;
+ u3x_mean(cor, u3x_sam_2, &a,
+ u3x_sam_3, &b, 0);
+ u3x_bite(a, &bloq, &step);
+
+ return u3qc_rsh(bloq, step, u3x_atom(b));
+}
+
+u3_noun
+u3kc_rsh(u3_noun a,
+ u3_noun b,
+ u3_noun c)
+{
+ u3_noun d = u3qc_rsh(a, b, c);
+
+ u3z(a); u3z(b); u3z(c);
+ return d;
+}