Activity 3.2

Source Code

-- define main function
function main()
    print("Hello Main Function")
    local choice = nil
    print("Menu")
    print("E1 - Example 1")
    print("Q - Quit")
    io.write("Choice: ")
    choice = io.read()
    if choice == "E1" then
        -- Example 1 Function call
        example1()

    elseif choice == "Q" then
        done = true
    else
        print("Invalid Choice")
    end
end

-- define Example 1 Function
function example1()
    -- create an empty list
    

    -- add an element to the end of the list (append)
    

    -- add an element to the end of the list (append)
    

    -- add an element to the beginning of the list (insert)
    

    -- print using for in loop
    

    -- print using for in loop with index
    

    -- delete a fruit
    

    -- print using for in loop
    

end

-- call to main function, do not delete!
main()

playlist.lua

Last updated

Was this helpful?