Elektrine lite

← Feed

@das_g@chaos.social

Post #2735403

2026-05-09 23:50 UTC

@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.

Replies (2)

  • @das_g@chaos.social 2026-05-09 23:52

    @byorgey@mathstodon.xyz It should be more efficient than explicitly replicating all those `()`s and then counting them again, but I don't know how its performance would compare to your «fiddly but efficient» version from above.

    Open ##2735404

  • @byorgey@mathstodon.xyz 2026-05-09 23:58

    @das_g@chaos.social Oh, that's very nice! I'm pretty sure that is behaviorally very close to my version, but implemented in a much nicer style.

    Open ##2735405