mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Added a comment to better demonstrate custom datatypes.
It is not obvious for a beginner (like me) to declare a new value of the temp datatype which can be either C (celsius) or F (fahrenheit). I think it would be better to demonstrate the declaration of such a datatype.
This commit is contained in:
parent
c85d93a5ed
commit
c4664b31e5
@ -273,6 +273,9 @@ datatype temp =
|
|||||||
C of real
|
C of real
|
||||||
| F of real
|
| F of real
|
||||||
|
|
||||||
|
(* Declaring a new C temp value...
|
||||||
|
val t: temp = C 45.0 *)
|
||||||
|
|
||||||
fun temp_to_f t =
|
fun temp_to_f t =
|
||||||
case t of
|
case t of
|
||||||
C x => x * (9.0 / 5.0) + 32.0
|
C x => x * (9.0 / 5.0) + 32.0
|
||||||
|
Loading…
Reference in New Issue
Block a user