My observation of ML frameworks from the POV of a functional programmer: PyTorch tensors are actually some kind of monad, with the dimensions being the "type" of the contained values. If you treat the ...
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible ...
The order of permutation of 0,1,2,3 is [0,1,2,3], [0,1,3,2], [0,2,1,3], [0,2,3,1], [0,3,1,2], [0,3,2,1], [1,0,2,3], [1,0,3,2], [1,2,0,3], ...