Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Dragon-curve/Haskell/dragon-curve-1.hs
Normal file
18
Task/Dragon-curve/Haskell/dragon-curve-1.hs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import Data.List
|
||||
import Graphics.Gnuplot.Simple
|
||||
|
||||
-- diamonds
|
||||
-- pl = [[0,1],[1,0]]
|
||||
|
||||
pl = [[0,0],[0,1]]
|
||||
r_90 = [[0,1],[-1,0]]
|
||||
|
||||
ip :: [Int] -> [Int] -> Int
|
||||
ip xs = sum . zipWith (*) xs
|
||||
matmul xss yss = map (\xs -> map (ip xs ). transpose $ yss) xss
|
||||
|
||||
vmoot xs = (xs++).map (zipWith (+) lxs). flip matmul r_90.
|
||||
map (flip (zipWith (-)) lxs) .reverse . init $ xs
|
||||
where lxs = last xs
|
||||
|
||||
dragoncurve = iterate vmoot pl
|
||||
11
Task/Dragon-curve/Haskell/dragon-curve-2.hs
Normal file
11
Task/Dragon-curve/Haskell/dragon-curve-2.hs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
x 0 = ""
|
||||
x n = (x$n-1)++" +"++(y$n-1)++" f +"
|
||||
y 0 = ""
|
||||
y n = " - f"++(x$n-1)++" -"++(y$n-1)
|
||||
|
||||
dragon n =
|
||||
concat ["0 setlinewidth 300 400 moveto",
|
||||
"/f{2 0 rlineto}def/+{90 rotate}def/-{-90 rotate}def\n",
|
||||
"f", x n, " stroke showpage"]
|
||||
|
||||
main = putStrLn $ dragon 14
|
||||
Loading…
Add table
Add a link
Reference in a new issue