tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View 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

View 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