Skip to content

Instantly share code, notes, and snippets.

@illusory0x0
Last active March 15, 2025 14:36
Show Gist options
  • Select an option

  • Save illusory0x0/fe4d4aa55ecf47d2cae7c8e5561282b2 to your computer and use it in GitHub Desktop.

Select an option

Save illusory0x0/fe4d4aa55ecf47d2cae7c8e5561282b2 to your computer and use it in GitHub Desktop.
lazy pattern match in Haskell
import Data.Function (fix)
-- lazy pattern match example
(is_odd, is_even) =
fix
( \ ~(is_odd, is_even) ->
( (\n -> if n == 0 then False else is_even (n - 1))
, (\n -> if n == 0 then True else is_odd (n - 1))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment