// negabinary // http://earl.strain.at/space/comments-2004-11-28 // approach 1: lut d: {_+/(x^|!#y)@&y} n: d[-2]'b:2_vs'!_9^5 e: b@n? // approach 2: translate mathematica code // cf. http://library.wolfram.com/conferences/devconf99/challenge m: {_-.5*x-x!2} f: 1_|![;2](~0=)m\ g: 1_|![;2](~0=){_-.5*x-x!2}\ rest: 1_ reverse: |: mod2: ![;2] notZero: ~0= negativeHalf: _-.5* core: {negativeHalf x-mod2 x} rest reverse mod2 notZero core\ // and then, it collapses 1_|![;2](~0=){_-.5*x-x!2}\ 1_|![;2](~0=)(-_.5*)\ 1_|![;2]0-(-_.5*)\ 1_|![;2]'(-_.5*)\