I got bored, so i started to write a binary decoder, i thought it would be usefull and end the multiple "ifs"...
well i havent used it yet, anyway...
well i havent used it yet, anyway...
[SELECT ALL] Code:
//// binary script by =SA=macm ////
// example of usage:
// /echo (bin 0 1 1 0) Output= 6
// /x = (bin 1 0 0 1 0 0 0 1); echo $x Output= 145
//this is an alternative addon, it will "add2alias" but not with the ";"
add2alias_ = [
if (strcmp "" (getalias $arg1)) [
$arg1 = $arg2] [
$arg1 = (concat (getalias $arg1) $arg2)
]
]
alias execbinlist [alias binlist [0 1]; muln = 1; loop i 20 [muln = (* $muln 2); add2alias_ binlist $muln]]
alias bin [
curnumargs = $numargs;
execbinlist; fbin; 1bin]
alias fbin [
s = 0;
read_;
alias 1bin [];
add2alias_ 1bin "(+m";
loop i (+ $curnumargs 1) [if (= $i 0) [] [ z = (- $curnumargs $s); s = (+ $s 1);
add2alias_ 1bin (concatword "(* " (at $binlist $z) " $arg" $i ")")
]];
add2alias_ 1bin ")"
]
alias read_ [
+m = [];
loop k (+ $curnumargs 1) [if (= $k 0) [] [
+m = (concatword "(+ " $+m " $arg" $k ")") ]]
]