isCallable
This commit is contained in:
parent
64e716af6f
commit
9893a8bd97
1
src/h.h
1
src/h.h
@ -289,6 +289,7 @@ bool isF64(B x) { return (x.u<<1) - ((0xFFEull<<52) + 2) >= (1ull<<52) - 2; }
|
|||||||
bool isNum(B x) { return isF64(x)|isI32(x); }
|
bool isNum(B x) { return isF64(x)|isI32(x); }
|
||||||
|
|
||||||
bool isAtm(B x) { return !isArr(x); }
|
bool isAtm(B x) { return !isArr(x); }
|
||||||
|
bool isCallable(B x) { return isMd(x) | isFun(x); }
|
||||||
bool noFill(B x);
|
bool noFill(B x);
|
||||||
|
|
||||||
// shape mess
|
// shape mess
|
||||||
|
|||||||
@ -60,14 +60,13 @@ int main() {
|
|||||||
|
|
||||||
// uncomment to self-compile and use that for the REPL
|
// uncomment to self-compile and use that for the REPL
|
||||||
// expects a copy of mlochbaum/BQN/src/c.bqn to be at the execution directory (with •args replaced with the array in glyphs.bqn)
|
// expects a copy of mlochbaum/BQN/src/c.bqn to be at the execution directory (with •args replaced with the array in glyphs.bqn)
|
||||||
|
|
||||||
// char* c_src = NULL;
|
// char* c_src = NULL;
|
||||||
// u64 c_len;
|
// u64 c_len;
|
||||||
// FILE* f = fopen("c.bqn", "rb");
|
// FILE* f = fopen("c.bqn", "rb");
|
||||||
// if (f) {
|
// if (f) {
|
||||||
// fseek(f, 0, SEEK_END);
|
// fseek(f, 0, SEEK_END); c_len = ftell(f);
|
||||||
// c_len = ftell(f);
|
// fseek(f, 0, SEEK_SET); c_src = malloc(c_len);
|
||||||
// fseek(f, 0, SEEK_SET);
|
|
||||||
// c_src = malloc(c_len);
|
|
||||||
// if (c_src) fread(c_src, 1, c_len, f);
|
// if (c_src) fread(c_src, 1, c_len, f);
|
||||||
// fclose(f);
|
// fclose(f);
|
||||||
// } else {
|
// } else {
|
||||||
@ -75,11 +74,13 @@ int main() {
|
|||||||
// }
|
// }
|
||||||
// if (c_src) {
|
// if (c_src) {
|
||||||
// bqn_setComp(bqn_exec(fromUTF8(c_src, c_len)));
|
// bqn_setComp(bqn_exec(fromUTF8(c_src, c_len)));
|
||||||
|
// // for (i32 i = 0; i < 100; i++) { dec(bqn_exec(fromUTF8(c_src, c_len))); gc_maybeGC(); }
|
||||||
// } else {
|
// } else {
|
||||||
// printf("couldn't read c.bqn\n");
|
// printf("couldn't read c.bqn\n");
|
||||||
// exit(1);
|
// exit(1);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
while (CATCH) {
|
while (CATCH) {
|
||||||
printf("caught: ");
|
printf("caught: ");
|
||||||
print(catchMessage);
|
print(catchMessage);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
bool isPureFn(B x) { // doesn't consume
|
bool isPureFn(B x) { // doesn't consume
|
||||||
if (!isFun(x) && !isMd(x)) return true;
|
if (!isCallable(x)) return true;
|
||||||
if (v(x)->flags) return true;
|
if (v(x)->flags) return true;
|
||||||
B2B dcf = TI(x).decompose;
|
B2B dcf = TI(x).decompose;
|
||||||
B xd = dcf(inc(x));
|
B xd = dcf(inc(x));
|
||||||
|
|||||||
@ -95,7 +95,7 @@ void printRaw(B x) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
B def_decompose(B x) { return m_v2(m_i32((isFun(x)|isMd(x))? 0 : -1),x); }
|
B def_decompose(B x) { return m_v2(m_i32(isCallable(x)? 0 : -1),x); }
|
||||||
bool atomEqual(B w, B x) { // doesn't consume (not that that matters really currently)
|
bool atomEqual(B w, B x) { // doesn't consume (not that that matters really currently)
|
||||||
if(isF64(w)&isF64(x)) return w.f==x.f;
|
if(isF64(w)&isF64(x)) return w.f==x.f;
|
||||||
if (w.u==x.u) return true;
|
if (w.u==x.u) return true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user