a gleam implementation of a CS assignment originally written in cpp

Project: "#6" Professor: "Professor Knoerr" Class: "CS 1210 – Fall 2025" Author: "Kieran Klukas"#

Requirements#

Search a provided old testament text file for arbitrary reference. It prompts the user for book, chapter, and verse and then searches for that verse. If book is not found then output Book does not exist in the Old Testament. If chapter isn't found then Chapter # does not exist in Book. Finally if the verse isn't found then output Verse # does not exist in Book #. Once the verse is found then append the verse to verses.txt.

Design#

I started with outlining the basic input system 532c6cf. Then worked on setting up a while loop to read the file line by line. I spent a while puzzling over exactly how I wanted to implement this and I am not entirely satisfied with my current solution. It would be interesting to try this problem in a functional language like gleam or erlang and see how much more cleanly I can parse the file. I implemented each reference part sequentially and then went back and made it check for barrier strings to stay within the proper book and chapter. I ended up realizing that the book of Psalms is referenced differently and so made some logic to permit its idiosyncracies 7c18fff.

Implementation#

I used a single input variable to parse the file word by word until we get to the correct verse. I also check if the input book is listed as Psalm or Psalms and add or remove an s when doing checks or output as appropriate. The output file is also never opened until we find the verse and is immediately closed afterward. Also a minor note of intrest is that you can change the default paths that the program loads from and saves to by adding the paths as arguments (eg. lab66 test/OT.txt build/verses.txt).

Testing#

I updated the makefile to add make run so I could compile and run it more easily and updated the test file to have the Zylabs test states as well as more granularly check a happy path and some adversarial paths.

Outside Help#

No outside help was used beyond minor googling for how to capitalize an entire string and the proper syntax for appending (not covered in zybooks as far as I can tell but I'm sure you will cover it in lectures next week).

Summary/Conclusion#

The program works well and should cover most edgecases! As far as I can tell there isn't anything that should be able to break it beyond changing the OT.txt to be several GB in size.

AI Use#

I used claude to generate a more complex test file and then modified it to add the rest of the zybooks tests as I got closer to finishing the project.

Lessons Learned#

I would definetly want to try a different language for sure if I was doing this independantly but overal I think this implementation is fairly solid and I wouldn't change much. I did find out in this lab that it is always a good idea to check the whole input or you might run into weird bugs like how PSALMS is formatted.

Time Spent#

hackatime badge