2048: Difference between revisions
→{{header|J}}: correct merging directions
(→{{header|J}}: name target) |
(→{{header|J}}: correct merging directions) |
||
Line 1,406:
newnum=: verb define
num=.
idx=. 4 $. $. 0 = y NB. indicies of 0s
if. #idx do. NB. handle full grid
Line 1,420:
compress=: -.&0
toLeft=: 1 :'4&{.@(u@compress
toRight=: 1 : '_4&{.@(u@compress&.|.)"1'
toUp=: 1 : '(4&{.@(u@compress
toDown=: 1 : '(_4&{.@(u@compress&.|.)"1)&.|:'
move=: conjunction define
|