Comment detail

法演算 (Nested Flatten)
   7 plus 3
7 + 3 = 0
0
   2 minus 3
2 - 3 = 9
9
   16 times 12
16 * 12 = 6 * 2 = 2
2
    10 plus 12 times _2 minus 3
_2 - 3 = 5
12 * 5 = 2 * 5 = 0
10 + 0 = 0 + 0 = 0
0
j言語の演算順序は、右結合で動詞の優先順位なしです。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
print=:(1!:2)&2

calc=:2 :0
:
a=.(":x),n,":y
b=.>(+./(x,y)>:m){'';(' = ',":m|x),n,":m|y
c=.m|".a
print a,b,' = ',":c
c
)

plus=:10 calc ' + '
minus=:10 calc ' - '
times=:10 calc ' * '

Index

Feed

Other

Link

Pathtraq

loading...