reorder eachm_fn and eachd_fn args

This commit is contained in:
dzaima 2022-08-18 11:18:34 +03:00
parent cab354265b
commit 719d37cd63
3 changed files with 10 additions and 10 deletions

View File

@ -7,7 +7,7 @@
static inline B arith_recm(BB2B f, B x) {
B fx = getFillQ(x);
B r = eachm_fn(f, bi_N, x);
B r = eachm_fn(bi_N, x, f);
return withFill(r, fx);
}

View File

@ -4,7 +4,7 @@
static inline B mv(B* p, usz n) { B r = p [n]; p [n] = m_f64(0); return r; }
static inline B hmv(HArr_p p, usz n) { B r = p.a[n]; p.a[n] = m_f64(0); return r; }
B eachd_fn(BBB2B f, B fo, B w, B x) {
B eachd_fn(B fo, B w, B x, BBB2B f) {
if (isAtm(w)) w = m_atomUnit(w);
if (isAtm(x)) x = m_atomUnit(x);
ur wr = rnk(w); SGet(w);
@ -51,7 +51,7 @@ B eachd_fn(BBB2B f, B fo, B w, B x) {
return any_squeeze(rb);
}
B eachm_fn(BB2B f, B fo, B x) { // TODO definitely rewrite this. Probably still has refcounting errors
B eachm_fn(B fo, B x, BB2B f) { // TODO definitely rewrite this. Probably still has refcounting errors
usz ia = a(x)->ia;
if (ia==0) return x;
SGet(x);

View File

@ -1,12 +1,12 @@
#pragma once
#include "mut.h"
B eachd_fn(BBB2B f, B fo, B w, B x); // consumes w,x; assumes at least one is array
B eachm_fn(BB2B f, B fo, B x); // consumes x; x must be array
B eachd_fn(B fo, B w, B x, BBB2B f); // consumes w,x; assumes at least one is array
B eachm_fn(B fo, B x, BB2B f); // consumes x; x must be array
static B eachm(B f, B x) { // complete F¨ x without fills; consumes x
if (isAtm(x)) return m_hunit(c1(f, x));
if (isFun(f)) return eachm_fn(c(Fun,f)->c1, f, x);
if (isFun(f)) return eachm_fn(f, x, c(Fun,f)->c1);
if (isMd(f)) if (isAtm(x) || a(x)->ia) { decR(x); thrM("Calling a modifier"); }
usz ia = a(x)->ia;
@ -17,16 +17,16 @@ static B eachm(B f, B x) { // complete F¨ x without fills; consumes x
static B eachd(B f, B w, B x) { // complete w F¨ x without fills; consumes w,x
if (isAtm(w) & isAtm(x)) return m_hunit(c2(f, w, x));
return eachd_fn(c2fn(f), f, w, x);
return eachd_fn(f, w, x, c2fn(f));
}
#if CATCH_ERRORS
static inline B arith_recd(BBB2B f, B w, B x) {
B fx = getFillQ(x);
if (noFill(fx)) return eachd_fn(f, bi_N, w, x);
if (noFill(fx)) return eachd_fn(bi_N, w, x, f);
B fw = getFillQ(w);
B r = eachd_fn(f, bi_N, w, x);
B r = eachd_fn(bi_N, w, x, f);
if (noFill(fw)) { dec(fx); return r; }
if (CATCH) { freeThrown(); return r; }
B fr = f(bi_N, fw, fx);
@ -35,6 +35,6 @@ static inline B arith_recd(BBB2B f, B w, B x) {
}
#else
static inline B arith_recd(BBB2B f, B w, B x) {
return eachd_fn(f, bi_N, w, x);
return eachd_fn(bi_N, w, x, f);
}
#endif