Skip to content

Instantly share code, notes, and snippets.

@ab9rf
Last active December 16, 2015 13:19
Show Gist options
  • Save ab9rf/5441088 to your computer and use it in GitHub Desktop.
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.
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