Last active
December 16, 2015 13:19
-
-
Save ab9rf/5441088 to your computer and use it in GitHub Desktop.
This is a Haskell implementation of the same algorithm as found here http://python.nulldoc.com/draw_triangle Solely for illustrative purposes; this isn't useful for anything.
This file contains hidden or 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
drawTriangle size c s = | |
concat (map line [0..size-1]) | |
where line i = map (charAt i) [0..size*2-1] ++ "\n" | |
charAt i j | size + i == j = c | |
| size - i == j = c | |
| (size - 1 == i) && (j > 0) = c | |
| otherwise = s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment