/* * Copyright 2020 Esben Bjerre * * Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE.md file. */pubmod Comparison {pubenumComparisonwithEq, ToString {case LessThancase EqualTocase GreaterThan }////// Converts a `Comparison` value to an integer./// The return value is:/// `-1` if `c` is `LessThan`./// `0` if `c` is `EqualTo`./// `+1` if `c` is `GreaterThan`.///pubdeftoInt32(c: Comparison): Int32 = matchc {case LessThan => -1case EqualTo => 0case GreaterThan => 1 }////// Converts an integer to a `Comparison` value./// The return value is:/// `LessThan` if `i < 0`./// `EqualTo` if `i == 0`./// `GreaterThan` if `i > 0`.///pubdeffromInt32(i: Int32): Comparison =if (i<0) LessThanelseif (i==0) EqualToelse GreaterThan}