diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-09-11 17:05:59 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-09-11 17:05:59 -0400 |
commit | c32df123269f83959a478d99e4d231d4cdc93b8d (patch) | |
tree | 042e30a2f42e930e4f36739f50af7cda59a06bce /percolation.hs | |
parent | 3927aa090dfed22c3224bb31d1bdb7c0bdc14759 (diff) | |
download | percolation-c32df123269f83959a478d99e4d231d4cdc93b8d.tar.gz percolation-c32df123269f83959a478d99e4d231d4cdc93b8d.tar.bz2 percolation-c32df123269f83959a478d99e4d231d4cdc93b8d.zip |
modified algorthim to use Newman and Ziff's, started haskell implementation
Diffstat (limited to 'percolation.hs')
-rw-r--r-- | percolation.hs | 24 |
1 files changed, 24 insertions, 0 deletions
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] + ] + + + + |