{-  
    COMS 4995: Parallel Functional Programming, Fall 2025
    Quiz 2: Basic datatypes

    1. Close all devices (phone/laptop, etc). Make sure you have an index card to write on, and a pen/pencil.

    2. PLEASE WRITE YOUR NAME AND UNI AS LEGIBLY AS POSSIBLE

    3. Read the quiz question below, and write your answer on your index card. CIRCLE YOUR ANSWER.

    4. Turn in your card at the table in the front of the room.
-}

-- Consider the `Foo` datatype defined below
data Foo = Bar    Int
         | Baz    Foo Int Int
         | FooBar Foo Int

-- ...And an associated transformation function
fooToList :: Foo -> [Int]
fooToList (Bar x)        = [x]
fooToList (Baz foo x y)  = x:(fooToList foo) ++ [y]
fooToList (FooBar foo x) = x:(fooToList foo)

-- QUESTION:
-- What is the result of
-- `fooToList (FooBar (Baz (Bar 1) 5 6) 9)`?

-- CORRECT ANSWER:
-- [9,5,1,6]

-- EXPLANATION:
-- Initial argument to fooToList is a FooBar, matches line 23 so we get 9:(fooToList (Baz (Bar 1) 5 6))
-- Argument to the recursive call is a Baz,   matches line 22 so we get 9:(5:(fooToList (Bar 1)) ++ [6])
-- Argument to the recursive call is a Bar,   matches line 21 so we get 9:(5:([1]) ++ [6]) == [9,5,1,6]