user9183739
user9183739

Reputation:

Koch snowflake in Haskell (CodeWorld)

Through the Haskell package, CodeWorld (https://hackage.haskell.org/package/codeworld-api) , I need to draw Koch's snowflake.

You can use this package online, in case you don't want to download it: https://code.world/#

A link so you can see what I need to do: https://upload.wikimedia.org/wikipedia/commons/f/fd/Von_Koch_curve.gif

I'm not quite sure how it would be done, can you help me?

And if by the way, you know some manuals to work with this package, well much better.

I've done this:

import CodeWorld

main :: IO ()
main = drawingOf triangle

triangle :: Picture
triangle = polygon [(9,9),(0,-9),(-9,9)]

Upvotes: 0

Views: 459

Answers (1)

Paul Johnson
Paul Johnson

Reputation: 17786

I'm going to answer in the most general terms, because I'm not going to do your homework for you.

You need a type to represent a line between two points. You need a function that takes one line and returns 4, where the new 4 lines are the

_/\_ 

pattern of the Koch snowflake. Then you need a recursive function to call it to the right depth.

Upvotes: 0

Related Questions