Measure the wildlife labels
Before you start this master track
Functions and immutable lists. Read type signatures, pattern matching, and guards.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
Haskell functions transform values without changing the original input. map applies a function to every item of a list, preserving its order. Here length measures each animal name, producing a new list of label widths. The indentation under do groups the small steps that prepare and print the result.
main :: IO ()main = do let names = ["ox", "heron", "lynx"] let widths = map length names print widthsEach mission is a separate Haskell 2010 program using the standard Prelude. Save one as Main.hs and run with runghc Main.hs. String output uses putStrLn; numeric lists use print.
Track the values line by line. Predict the result before running this example in your own editor.