diff --git a/src/builtins/arithd.c b/src/builtins/arithd.c index 8fbb76c9..2bd6d818 100644 --- a/src/builtins/arithd.c +++ b/src/builtins/arithd.c @@ -200,6 +200,7 @@ GC2i(not, 1+wv-xv, {}) GC2f(div , w.f/x.f, {}) GC2f(pow , pow(w.f, x.f), {}) +GC2f(root , pow(x.f, 1.0/w.f), {}) GC2f(floor, fmin(w.f, x.f), {}) GC2f(ceil , fmax(w.f, x.f), {}) GC2f(stile, pfmod(x.f, w.f), {}) diff --git a/src/builtins/arithm.c b/src/builtins/arithm.c index 002a88b1..30d498c4 100644 --- a/src/builtins/arithm.c +++ b/src/builtins/arithm.c @@ -16,6 +16,7 @@ B not_c1(B t, B x) { if (isF64(x)) return m_f64( 1-x.f ); P1( not); thrM(" B mul_c1(B t, B x) { if (isF64(x)) return m_f64(x.f==0?0:x.f>0?1:-1); P1(mul); thrM("×: Getting sign of non-number"); } B div_c1(B t, B x) { if (isF64(x)) return m_f64( 1/x.f ); P1( div); thrM("÷: Getting reciprocal of non-number"); } B pow_c1(B t, B x) { if (isF64(x)) return m_f64( exp(x.f)); P1( pow); thrM("⋆: Getting exp of non-number"); } +B root_c1(B t, B x) { if (isF64(x)) return m_f64( sqrt(x.f)); P1( root); thrM("√: Getting root of non-number"); } B floor_c1(B t, B x) { if (isF64(x)) return m_f64(floor(x.f)); P1(floor); thrM("⌊: Argument was not a number"); } B ceil_c1(B t, B x) { if (isF64(x)) return m_f64( ceil(x.f)); P1( ceil); thrM("⌈: Argument was not a number"); } B stile_c1(B t, B x) { if (isF64(x)) return m_f64( fabs(x.f)); P1(stile); thrM("|: Argument was not a number"); } diff --git a/src/load.c b/src/load.c index 63053a87..79dfac56 100644 --- a/src/load.c +++ b/src/load.c @@ -149,7 +149,7 @@ static inline void load_init() { // very last init function comp_currArgs = bi_N; gc_addFn(load_gcFn); B fruntime[] = { - /* +-×÷⋆√⌊⌈|¬ */ bi_add , bi_sub , bi_mul , bi_div , bi_pow , bi_N , bi_floor, bi_ceil , bi_stile , bi_not, + /* +-×÷⋆√⌊⌈|¬ */ bi_add , bi_sub , bi_mul , bi_div , bi_pow , bi_root , bi_floor, bi_ceil , bi_stile , bi_not, /* ∧∨<>≠=≤≥≡≢ */ bi_and , bi_or , bi_lt , bi_gt , bi_ne , bi_eq , bi_le , bi_ge , bi_feq , bi_fne, /* ⊣⊢⥊∾≍↑↓↕«» */ bi_ltack , bi_rtack , bi_shape, bi_join , bi_couple , bi_take , bi_drop , bi_ud , bi_shifta, bi_shiftb, /* ⌽⍉/⍋⍒⊏⊑⊐⊒∊ */ bi_reverse, bi_N , bi_slash, bi_gradeUp, bi_gradeDown, bi_select, bi_pick , bi_indexOf, bi_count , bi_memberOf, @@ -158,7 +158,7 @@ static inline void load_init() { // very last init function /* ⚇⍟⎊ */ bi_N , bi_repeat, bi_catch }; bool rtComplete[] = { - /* +-×÷⋆√⌊⌈|¬ */ 1,1,1,1,1,0,1,1,1,1, + /* +-×÷⋆√⌊⌈|¬ */ 1,1,1,1,1,1,1,1,1,1, /* ∧∨<>≠=≤≥≡≢ */ 1,1,1,1,1,1,1,1,1,1, /* ⊣⊢⥊∾≍↑↓↕«» */ 1,1,0,1,1,1,1,1,1,1, /* ⌽⍉/⍋⍒⊏⊑⊐⊒∊ */ 1,0,1,1,1,1,1,1,1,1, diff --git a/src/utils/builtins.h b/src/utils/builtins.h index fe25e7af..291eb74d 100644 --- a/src/utils/builtins.h +++ b/src/utils/builtins.h @@ -1,7 +1,7 @@ #pragma once #define FOR_PFN(A,M,D) \ -/* arith.c*/A(add,"+") A(sub,"-") A(mul,"×") A(div,"÷") A(pow,"⋆") A(floor,"⌊") A(ceil,"⌈") A(stile,"|") A(eq,"=") \ +/* arith.c*/A(add,"+") A(sub,"-") A(mul,"×") A(div,"÷") A(pow,"⋆") A(root,"√") A(floor,"⌊") A(ceil,"⌈") A(stile,"|") A(eq,"=") \ /* arith.c*/A(ne,"≠") D(le,"≤") D(ge,"≥") A(lt,"<") A(gt,">") A(and,"∧") A(or,"∨") A(not,"¬") A(log,"⋆⁼") \ /* fns.c*/A(ud,"↕") A(fne,"≢") A(feq,"≡") A(ltack,"⊣") A(rtack,"⊢") M(fmtF,"•FmtF") A(indexOf,"⊐") A(memberOf,"∊") A(find,"⍷") A(count,"⊒") \ /* sfns.c*/A(shape,"⥊") A(pick,"⊑") A(pair,"{𝕨‿𝕩}") A(select,"⊏") A(slash,"/") A(join,"∾") A(couple,"≍") A(shiftb,"»") A(shifta,"«") A(take,"↑") A(drop,"↓") A(group,"⊔") A(reverse,"⌽") \