LMU ☀️ CMSI 3801
LANGUAGES AND AUTOMATA I
HOMEWORK #2 Due: 2025-09-19

Learning Objectives

With this assignment you will demonstrate:

Readings and Videos

Please:

Instructions

Work in teams of 1 to 4 students.

Do all work in the GitHub repository you created in the previous assignment.

Remember: There must be only one official repository per group.

Repository

Add files according to the folder structure below. You will be implementing the assigned functions and classes from scratch. The test files have been written for you; follow the links to obtain them.

.
├── code/
│   ├── python/
│   │   ├── exercises.py
│   │   └── exercises_test.py
│   ├── javascript/
│   │   ├── exercises.js
│   │   └── exercises.test.js
│   ├── lua/
│   │   ├── exercises.lua
│   │   └── exercises_test.lua

Code

Implement—for Lua, Python, and JavaScript—modules that contain:

Further instructions can be found in the unit tests, which serve to define the names and desired behaviors of the functions and classes, sometimes including the names of files and parameters, and how exactly the parameters should be passed. But keep in mind not every detail will be captured in the tests! The following requirements will be inspected during manual grading:

Strive to use the most idiomatic constructs of each language in your solutions.

Generative AI is permitted for this assignment; however, there is no guarantee that it will produce code that meets all of the requirements. Do not try to prompt your way to working solutions. Make sure to thoroughly review and test any code produced by AI tools.

To use the supplied unit tests, you should create a folder called test-data (as a sibling of code and exercises), that contains a single file called test-for-line-count.txt with the following contents:


  hello

😁👩🏽‍🎤 👩🏽‍🎤🧑🏻‍🔧 🧑🏻‍🔧     🧑🏻‍🔧

    # hash1
# hash2 ####

  hash is not at the beginning # ⇐⇐⇐ but here





                     ----
last

Run the tests in their corresponding code folders, with the following commands:

Exercises

In the file exercises/hw2.md, provide solutions to the following problems. You will need to do research, as not all of these topics were covered in class. For exercises that ask you for prose answers, please be comprehensive and demonstrate a broad understanding. But avoid long-winded, silly gen-ai answers. Expect deductions for verbatim copies of AI slop. Be precise and concise.

  1. Why is the null reference so hideous?
  2. Why did Tony Hoare introduce the null reference, even though he felt like it was wrong and his friend Edsger Dijkstra said it was a bad idea?
  3. In JavaScript 3**35 = 50031545098999710 but in Python 3**35 = 50031545098999707. Which one is right and which is wrong? Why? Explain exactly why the right value is right and the wrong value is that particular wrong value.
  4. What is the Python equivalent of JavaScript’s {x: 3, [y]: 5, z}?
  5. Why is it best to not call JavaScript’s == operator “equals” (even though people do it all the time)?
  6. Write a Lua function called arithmeticsequence that accepts two arguments, start and delta, that returns a coroutine such that each time it is resumed it yields the next value in the arithmetic sequence starting with start and incrementing by delta.
  7. What does this script print under (a) static scoping and (b) dynamic scoping?
    var x = 1
    function h() {var x = 9; return g();}
    function f() {return x;}
    function g() {var x = 3; return f();}
    print f() * h() - x
    
  8. Why does shallow binding not make much sense when combined with static scoping?

Please use professional and well-structured Markdown formatting for your answers. Take pride in your work. Show you care.

Submission

To submit your work, choose one and only one team member to submit to BrightSpace (1) the names of all team members, (2) the URL of your private repository, and (3) an affidavit for each team member stating that they have done the assigned book readings and reviewed the aforementioned course notes pages.

Teamwork

Remember that, when working in teams, all team members should participate in generating solutions and are responsible for understanding all submitted answers. Ideally, each team member should produce individual answers for all exercises, and the team should combine them to produce the ultimate submissions.

Grading

You will be graded both on the correctness of your solutions, adherence to each language’s conventions, the following of the assignment instructions, and the cleanliness of the repository. Feedback will be in the form of deductions for such things as:

This list is not exhaustive, but should help in getting you used to paying attention to your submissions and taking pride in your work. Note that most code editors have plugins that will auto-format your code and even look for suspicious coding practices. You are strongly encouraged to use them.

Your homework submission will be the state of your repository on your main branch, at 18:00 in the America/Los Angeles time zone on the due date.