NB. tree3oop.ijs wr =: 1!:2&2 rd =: 1!:1 tfd =: 3 : '3 #. ^:(_1) y' NB. ternary from decimal dft =: 3 : '3 #. y' NB. decimal from ternary NB. decimal to ternary ============================== NB. tern 50 => 1 2 1 2 tern =: 3 : 0 N =. y M =. N T =. '' i =. 0 while. i < (3 ^. N) NB. repeat while less than log N based on 3 do. wr 'M: ', ": M1 =. <. M % 3 NB. integer divide by 3 wr 'T: ', ": T =. (3|M), T NB. residue by 3, appended as upper digit if. M1 = 0 do. '** tern:', (":T) return. end. rd 1 M =. M1 i=. i + 1 end. ) NB. ternary to decimal ============================== NB. tern_to_dec 1 2 1 2 => 50 tern_to_dec =: 3 : '+/ y * 3 ^ |. i. #y' NB. gyakuten of ternary notation ==================== NB. gyakuten 100 NB. 1 0 2 0 1 NB. 1 0 2 0 1 NB. 1 gyakuten =: 3 : 0 wr 'N: ', (":y), ', T: ', ": T =. 3 #.(^:_1) y 'gyakuten: ', ": TT =. |. T ) gyaku =: 3 : 0"(0) T =. 3 #.(^:_1) y TT =. |. T T -: TT ) NB. gyakutensuu 50 NB. 0 1 2 4 8 10 13 16 20 23 26 28 40 gyakutensuu =: 3 : '(gyaku i. y)#(i. y)' NB. Acesss OOP =============================================== path =: 1!:43 '' path =: 7 {. path load path, '\system\j602-user\user\classes\ptree3.ijs' ooprun =: 3 : 0 ins =: '' conew 'ptree3' '** OOP loaded OK **', LF, '** ins created **', LF, 'try: tern__ins 20' ) run =: 3 : 0 ins =: 'd1' conew 'ptree3' run__ins y )