Ch6 Discussion 02
The cityscape
function takes in a list of integers representing the
heights of buildings and puts out a single string that will show
skyscrapers built of X’s in columns whose heights correspond to the
integers.
Example:
cityscape [4,2,6,1]
Output:
x
x
x x
x x
xxx
xxxx
Make sure you test your program to verify that it works with two skyscrapers of the same height.
Editing Checklist
- Only uses of
length
are absolutely essential. - Recursion uses
(x:xs)
nothead
andtail
. - Choices are made by patterns and guards, not
if...then...else
. - Functions have names that indicate what they do.
Last modified August 25, 2021: ap-cs 2019-2020 (4d1c12c)