Elektrine lite

← Feed

@jer_gib@functional.cafe

Post #2735431

2026-05-11 08:32 UTC

@byorgey@mathstodon.xyz There should also be a way to write that using `replicate n succ` directly, but now I have to rush off and do something less interesting.

Replies (1)

  • @jer_gib@functional.cafe 2026-05-11 09:58

    @byorgey@mathstodon.xyz For this you want the heterogeneous big brother of `lzw`: ``` lzw2 :: (a->b->c) -> a -> b -> [a] -> [b] -> [c] lzw2 f u v (x:xs) (y:ys) = f x y : lzw2 f u v xs ys lzw2 f u v xs [] = [ f x v | x [Int] conjugate' = foldr incr [] where incr n ms = lzw2 ($) id 0 (replicate n succ) ms ```

    Open ##2735432