Post #2735400
2026-05-09 19:13 UTC
Incidentally, if anyone wants to play with this, here's my fiddly but efficient version:
```
conjugatePartition :: [Int] -> [Int]
conjugatePartition ps = go (length ps) 0 ps
where
go :: Int -> Int -> [Int] -> [Int]
go !r !l [] = []
go !r !l ps@(p : _) = replicate (p - l) r ++ go (r - length pre) p rest
where
(pre, rest) = span (== p) ps
```
Replies (1)
-
@das_g@chaos.social 2026-05-09 23:50
@byorgey@mathstodon.xyz Geometrically (from how I'd draw the list of lists of `()`s; thus not algebraically like one would in a Bird-Meertens-style code transformation) I've derived the following implementation: conjugate :: [Int] -> [Int] conjugate [] = [] conjugate (n:ns) = concat $ zipWith replicate diffs [1..] where diffs :: [Int] diffs = zipWith (-) (n:ns) (ns ++ [0]) It assumes the input is non-negative and in non-increasing order and (like your original) gives the result in non-decreasing order.