Read the first arrival
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.
Pattern matching gives a function separate definitions for different input shapes. An empty list gets a friendly fallback. The entry:_ pattern separates a nonempty list into its first entry and an ignored remainder. Haskell tries these equations in order, making the empty case explicit and safe.
firstLine :: [String] -> StringfirstLine [] = "No entries"firstLine (entry:_) = entrymain :: IO ()main = putStrLn (firstLine ["Arrived", "Queued"])Each 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.