Last active
September 12, 2024 00:14
-
-
Save ijp/960a192ead1c24888701314ff837bf6f to your computer and use it in GitHub Desktop.
K2 PCA in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Prelude hiding (lookup) | |
import Data.Maybe | |
type Nat = Int -- !! | |
type Baire = Nat -> Maybe Nat | |
encode :: [Maybe Nat] -> Nat | |
encode = undefined | |
lookup :: Baire -> Baire -> Maybe Nat | |
lookup alpha beta = Just (step 0) | |
where step :: Nat -> Nat | |
step k = case alpha (encode [beta i | i <- [0..k]]) of | |
Just n -> n | |
Nothing -> step (k + 1) | |
prepend :: Nat -> Baire -> Baire | |
prepend n beta k | k == 0 = Just n | |
prepend n beta k | otherwise = beta (k - 1) | |
multiply :: Baire -> Baire -> Baire | |
multiply alpha beta n = (lookup alpha) (prepend n beta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment