×=
×
+ị1,-,0
A-r1¤ṗœs2ṚẎị@ȯµ€Uz0ZU⁹ŀ/ḅ3
二つの引数、取って完全なプログラム[x,y]
、そしてz
... z
され{A:-1, B:0, C:1}
た結果を出力します
オンラインでお試しください!注:ゴルフ法では速度が遅くなります-この変更されたバージョンは高速です(3単位のログ、各デカルト積の前の上限と増分)。
どうやって?
×= - Link 1 (1), B: list of trits L, list of trits R
× - L multiplied by... (vectorises):
= - L equal R? (vectorises)
× - Link -1 (2), A: list of trits L, list of trits R
× - L multiplied by R (vectorises)
+ị1,-,0 - Link 0 (3), C: list of trits L, list of trits R
+ - L plus R (vectorises)
1,-,0 - list of integers = [1,-1,0]
ị - index into (vectorises) - 1-based & modular, so index -2 is equivalent to
- index 1 which holds the value 1.
A-r1¤ṗœs2ṚẎị@ȯµ€Uz0ZU⁹ŀ/ḅ3 - Main link: list of integers [X,Y], integer Z
µ€ - for each V in [X,Y]:
A - absolute value = abs(V)
¤ - nilad followed by link(s) as a nilad:
- - literal minus one
1 - literal one
r - inclusive range = [-1,0,1]
ṗ - Cartesian power, e.g. if abs(V)=3: [[-1,-1,-1],[-1,-1,0],[-1,-1,1],[-1,0,-1],[-1,0,0],[-1,0,1],[-1,1,-1],[-1,1,0],[-1,1,1],[0,-1,-1],[0,-1,0],[0,-1,1],[0,0,-1],[0,0,0],[0,0,1],[0,1,-1],[0,1,0],[0,1,1],[1,-1,-1],[1,-1,0],[1,-1,1],[1,0,-1],[1,0,0],[1,0,1],[1,1,-1],[1,1,0],[1,1,1]]
- (corresponding to: [-13 ,-12 ,-11 ,-10 ,-9 ,-8 ,-7 ,-6 ,-5 ,-4 ,-3 ,-2 ,-1 ,0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ] )
2 - literal two
œs - split into equal chunks [[[-1,-1,-1],[-1,-1,0],[-1,-1,1],[-1,0,-1],[-1,0,0],[-1,0,1],[-1,1,-1],[-1,1,0],[-1,1,1],[0,-1,-1],[0,-1,0],[0,-1,1],[0,0,-1],[0,0,0]],[[0,0,1],[0,1,-1],[0,1,0],[0,1,1],[1,-1,-1],[1,-1,0],[1,-1,1],[1,0,-1],[1,0,0],[1,0,1],[1,1,-1],[1,1,0],[1,1,1]]]
Ṛ - reverse [[[0,0,1],[0,1,-1],[0,1,0],[0,1,1],[1,-1,-1],[1,-1,0],[1,-1,1],[1,0,-1],[1,0,0],[1,0,1],[1,1,-1],[1,1,0],[1,1,1]],[[-1,-1,-1],[-1,-1,0],[-1,-1,1],[-1,0,-1],[-1,0,0],[-1,0,1],[-1,1,-1],[-1,1,0],[-1,1,1],[0,-1,-1],[0,-1,0],[0,-1,1],[0,0,-1],[0,0,0]]]
Ẏ - tighten [[0,0,1],[0,1,-1],[0,1,0],[0,1,1],[1,-1,-1],[1,-1,0],[1,-1,1],[1,0,-1],[1,0,0],[1,0,1],[1,1,-1],[1,1,0],[1,1,1],[-1,-1,-1],[-1,-1,0],[-1,-1,1],[-1,0,-1],[-1,0,0],[-1,0,1],[-1,1,-1],[-1,1,0],[-1,1,1],[0,-1,-1],[0,-1,0],[0,-1,1],[0,0,-1],[0,0,0]]
- (corresponding to: [1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,-13 ,-12 ,-11 ,-10 ,-9 ,-8 ,-7 ,-6 ,-5 ,-4 ,-3 ,-2 ,-1 ,0 ] )
ị@ - get item at index V (1-based & modular)
ȯ - logical OR with V (just handle V=0 which has an empty list)
U - upend (big-endian -> little-endian for each)
0 - literal zero }
z - transpose with filler } - pad with MSB zeros
Z - transpose }
U - upend (little-endian -> big-endian for each)
/ - reduce with:
ŀ - link number: (as a dyad)
⁹ - chain's right argument, Z
3 - literal three
ḅ - convert from base