commit 70450a3f99634fc9bbb68f178bfc88a0f40e9855 Author: j4nk Date: Wed Feb 12 00:28:40 2025 -0500 Added exercises 2.2, 2.3, 2.4, and 2.5 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b18ccbd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +#* \ No newline at end of file diff --git a/02.02/answer.txt b/02.02/answer.txt new file mode 100644 index 0000000..848c185 --- /dev/null +++ b/02.02/answer.txt @@ -0,0 +1 @@ +I agree that it would be nice if we just had numbers but the implementation would be tough as when real numbers get very close to ints, it is not clear at what point you can switch to integer operations over FP operations on the backend. diff --git a/02.03/answer.txt b/02.03/answer.txt new file mode 100644 index 0000000..dc1206c --- /dev/null +++ b/02.03/answer.txt @@ -0,0 +1,3 @@ +The first function requires type constraint because n could be an integer or a real +The second function does not require type constraint because Math.sin takes a real to a real, meaning that the compiler would be able to infer that this function takes a real to a real +The third function requires type constraint because k could be an integer or a real diff --git a/02.04/answer.txt b/02.04/answer.txt new file mode 100644 index 0000000..670f49d --- /dev/null +++ b/02.04/answer.txt @@ -0,0 +1,3 @@ +For the first version of digit, an argument of ~1 would return the character corresponding to the character code before the character code for "0" and an argument of 10 would return the character code 10 character codes after "0" + +For the second version of digit, they would cause errors diff --git a/02.05/date.sml b/02.05/date.sml new file mode 100644 index 0000000..2dbde64 --- /dev/null +++ b/02.05/date.sml @@ -0,0 +1,23 @@ +fun valid_date (d:int, m:string) = if (m="January" orelse + m="March" orelse + m="May" orelse + m="July" orelse + m="August" orelse + m="October" orelse + m="December") andalso + d <= 31 andalso + d >= 0 then + true + else if (m="April" orelse + m="June" orelse + m="September" orelse + m="November") andalso + d <= 30 andalso + d >= 0 then + true + else if m="February" andalso + d <= 28 andalso + d >= 0 + then + true + else false