Koch curve: Difference between revisions
m
→{{header|Haskell}}: Retired Control.Arrow (***) in favour of Data.Bifunctor (bimap)
(Added C++ solution) |
m (→{{header|Haskell}}: Retired Control.Arrow (***) in favour of Data.Bifunctor (bimap)) |
||
Line 353:
Generates SVG for a Koch snowflake. To view, save to a text file with an .svg extension, and open in a browser.
<lang haskell>import
import Text.Printf (printf)
Line 369:
in go (pred n) =<< zip points xs
in ab : go n (ab, xy)
equilateralApex :: (Float, Float) -> (Float, Float) -> (Float, Float)
Line 388 ⟶ 387:
midThirdOfLine (a, b) (x, y) =
let (dx, dy) = ((x - a) / 3, (y - b) / 3)
f = bimap (dx +)
p = f (a, b)
in (p, f p)
-- TEST ---------------------------------------------------
|