A Significant Figures Calculator
When I was taking chemistry classes in 10th grade of high school, I wanted a way to calculate expressions involving significant figures--not merely calculating how many significant figures an expression had, but actually reducing expressions according to the (confusing) rules of significant figures. That project of mine began in late 2019 when I barely knew any Python.
I had then made a recursive descent parser completely from scratch without doing any reading, and it actually worked okay (the actual code is now private for good reason). But I hit a roadblock when it came to the number 0. I didn't know how to treat 0 in terms of its significant figures and interactions with other terms, and the younger me gave up.
Three years later, armed with much more programming experience and knowledge of more paradigms, languages, and tooling, I have finally written a working version of it. It's written in Haskell and hosted here.
And while Heroku's free tier still exists (it's going away soon), there is a web version here. The HTML, JS and CSS are all written in Haskell using DSLs. :)
Its implementation uses, among many other things:
- the parser combinator library parsec for elegant LL(1) parsing
- the property testing library QuickCheck for generating arbitrary tests
and supports a WHOLE LOTTA STUFF you'd want to do with sigfigs! Check it out.
As far as I can tell, it is the only program of its kind. Have fun with it, try to break it, and if you do please report an issue! :)