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
-- fish number ver.5 | |
type Flist = [[Integer]] | |
f5 :: Integer -> Integer | |
f5 x = m ([replicate (fromInteger x) 1],x) | |
m :: (Flist,Integer) -> Integer | |
m (b,x) = mRev (reverse (map (reverse.rm (<0)) b), x) | |
mRev :: (Flist,Integer) -> Integer |
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
-- constants | |
module Consts where | |
-- 近傍数 nn (自身+その横nnマスをもとに次の世代へ発展させる) | |
nn :: Integer | |
nn = 5 | |
-- 状態数 q (セルが取れる状態数) | |
q :: Integer |
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
type I = Integer | |
type M = [I] | |
g :: (M,I) -> I | |
g ([],x) = x | |
g (0:as,x) = f$g (as,x) where f y = y+1 | |
g (a:as,x) = g (clone l1 (g (as,x))++l2,x) | |
where | |
(l1,l2) = t$span (a<=) as | |
t (lis,[]) = (lis,[]) |
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
type I = Integer | |
type M = [I] | |
g :: (M,I) -> I | |
g ([],x) = x | |
g (0:as,x) = f$g (as,x) where f y = y+1 | |
g (a:as,x) = g (clone l1 (g (as,x))++l2,x) | |
where | |
(l1,l2) = t$span (a<=) as | |
t (lis,[]) = (lis,[]) |
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
type I = Integer | |
g :: [I] -> I -> I | |
g [] x = x-1 | |
g (0:as) x = g as (f x) where f y = y+1 | |
g (a:as) x = g (clone l1' (x+1)++l2) (x+1) | |
where | |
clone list 1 = list | |
clone list k = list ++ clone list (k-1) | |
(l1,l2) = span (a<=) as |
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
type I = Integer | |
pfgh :: [I] -> I -> I | |
pfgh list x | null l2 = x+1 | |
| null l1 = fpow (pfgh (head list -1 : tail l2)) x x | |
| otherwise = pfgh (init l1 ++ [x] ++ (head l2 -1) : tail l2) x | |
where | |
(l1,l2) = span (<=0) list | |
fpow :: (a -> a) -> I -> (a -> a) |
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
type I = Integer | |
data F3 = S [I] | SS I deriving Show | |
sss :: [F3] -> I -> I | |
sss [] _ = 0 | |
sss (S []:ns) x = sss ns x | |
sss [S [1]] x = fpow f x x where f y = y+1 | |
sss (S (1:ns):nss) x = fpow (sss (S ns:nss)) x x | |
sss (S (n:ns):nss) x = sss (S (n'++ns):nss) x where n'=replicate (fromIntegral x) (n-1) | |
sss (SS 1:nss) x = sss (S [x]:nss) x |
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
type I = Integer | |
data F3 = S [I] | SS I | |
instance Show F3 where | |
show (S x) = show x | |
show (SS x) = show x | |
sss :: [F3] -> IO I -> IO I | |
sss [] x = do | |
x' <- x |
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 math | |
from numbers import Number | |
class Dual: | |
def __init__(self,z): | |
(self.x,self.y) = z | |
def __str__(self): | |
if self.y >= 0 : |
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
inivels = (0,-1) | |
fp = open('col.dat','w') | |
def col(vels,a): | |
(u,v) = vels # u : small ball || v : large ball | |
uu = ((1-a)*u + 2*a*v)/(1+a) | |
vv = (2*u + (a-1)*v)/(1+a) | |
return (uu,vv) | |
def cols(vels,a): |