It looks like I was last searching for 12-member sets of permutations of 7 which come close to generating every possible permutation of seven elements, as well as meeting a few other criteria, for an electronics project. It ended up being more like 10 lines plus comments, though, plus a big table generated by GAP, which I formatted into a Haskell list using probably a line of Haskell plus file loading.
Unfortunately for providing code, me playing with the finished algorithm has eaten up my whole 100 lines of history. So, here’s a two-liner I posted on Lemmy before, that implements a feed-forward neural net. It’s not exactly what you asked for, but it gives you an idea.
In practice, you might also need to define relu in another line:
relu x = if x > 0 then x else 0
Edit: No wait, I think that was a different problem related to the same project. There’s another module attached that generates all permutations of n items. After breaking it up so it’s a bit less write-only:
<span style="color:#323232;">allPermutations :: Int -> [[Int]]
</span><span style="color:#323232;">allPermutations 1 = [[0]]
</span><span style="color:#323232;">allPermutations n = concat $ map (addItem $ allPermutations (n-1) ) [0..(n-1)]
</span><span style="color:#323232;">
</span><span style="color:#323232;">addItem :: [[Int]] -> Int -> [[Int]]
</span><span style="color:#323232;">addItem old new = map (y -> new : map (fitAround new) y) old
</span><span style="color:#323232;">
</span><span style="color:#323232;">fitAround :: Int -> Int -> Int
</span><span style="color:#323232;">fitAround n y
</span><span style="color:#323232;"> | y >= n = y+1
</span><span style="color:#323232;"> | otherwise = y
</span>