From c32df123269f83959a478d99e4d231d4cdc93b8d Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 11 Sep 2019 17:05:59 -0400 Subject: modified algorthim to use Newman and Ziff's, started haskell implementation --- percolation.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 percolation.hs (limited to 'percolation.hs') diff --git a/percolation.hs b/percolation.hs new file mode 100644 index 0000000..1f66375 --- /dev/null +++ b/percolation.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE BangPatterns #-} +import Control.Monad.State (State, get, put, runState, state) +import Data.Array (Array) + +data Tree = Root Int Int | Node Int Tree + +data Forest = Array Int Tree + +findRoot :: Tree -> (Int, [(Int, Tree)]) +findRoot (Root i n) = (i, []) +findRoot (Node i t) = (r, [(i, Node i ] ++ []) + + + +squareLatticeEdges :: Int -> Int -> [(Int, Int)] +squareLatticeEdges d l = + [ (i, (l ^ j) * quot i (l ^ j) + mod (l ^ j + i + l ^ (j - 1)) (l ^ j)) + | j <- [1 .. d] + , i <- [0 .. (l ^ d) - 1] + ] + + + + -- cgit v1.2.3-54-g00ecf