Starting from:

$25

ProgrammingLanguages - HW0 - Solved

Programming Languages 





Download hw0provided.sml from the course website. The provided SML code defines three functions. There is only one problem in this assignment:

1. The provided function f uses addition where it should use multiplication. In the line defining the function f, replace the + with * to fix this bug.

To test your work, you can start with the provided file hw0test.sml and add more tests, or you can make your own testing file. The material in Section 1 explains how to write and use test files. The page on installing and using SML and Emacs is also helpful. Of course, this “fake assignment” is so simple, you can try turning it in without writing or running tests, which is definitely a bad idea for the real assignments. For the real assignments, the provided tests are very minimal, designed only to help you understand the necessary format of the solution.

Summary
Evaluating a correct homework solution should generate these bindings (but for this “fake assignment” the provided code will generate these bindings whether or not you fix the bug):

val f = fn : int * int -> int val double = fn : int -> int val triple = fn : int -> int

Of course, generating these bindings does not guarantee that your solutions are correct. Test your functions: Put your testing code in a separate file. We will not grade the testing file, nor will you turn it in, but surely for real assignments you will want to run your functions and record your test inputs in a file.

More products