Added exercises 2.2, 2.3, 2.4, and 2.5
This commit is contained in:
commit
70450a3f99
|
@ -0,0 +1,2 @@
|
||||||
|
*~
|
||||||
|
#*
|
|
@ -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.
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue