The script requests/brainstorming thread!
(16 Apr 11, 07:16AM)V-Man Wrote: That's great! So efficient! Can you think of an efficient script for "powf"?

Lol, I have come to a dead end.
Code:
powf = (stuff using log2 and powf)

Updated gcd and isint.
Code:
// Euclidean algorithm gcd = [ if (modf $arg1 $arg2) [ result (gcd $arg2 (modf $arg1 $arg2)) ] [ result $arg2 ] ] // determines whether the number is an int or not isint = [ result (=f (+ $arg1) $arg1) ] // returns the fraction of a rational number // precondition: arg1 is a rational number e.g. 0.35 tofract = [ result (simplify $arg1 1) ] // returns the fraction of an irrational number // precondition: arg1 is the repeating portion of an irrational number e.g. 0.66666... -> 0.6 itofract = [ result (simplify $arg1 0.9) ] // returns the simplified fraction simplify = [ tmpnum1 = $arg1 tmpnum2 = $arg2 while [ (|| (! (isint $tmpnum1)) (! (isint $tmpnum2))) ] [ *=f tmpnum1 10; *=f tmpnum2 10 ] tmpgcd = (gcd $tmpnum1 $tmpnum2) result (concat (divf $tmpnum1 $tmpgcd) (divf $tmpnum2 $tmpgcd)) ] // XXX: works only if powf is implemented correctly nthroot = [ result (powf 2 (divf (log2 $arg2) $arg1)) ] // XXX: fail recursive powf = [ result (powf 2 (*f $arg2 (log2 $arg1))) ]



Bit manipulation, pl0x...
Code:
i = 1 j = 2 += i $j j = (- $i $j) -= i $j
Code:
i = 1 j = 2 ^= i $j j = (^ $i $j) ^= i $j
Thanks given by:


Messages In This Thread
RE: The script requests/brainstorming thread! - by Yarukinasu - 17 Apr 11, 06:11PM