以下、力任せにに色々と記述しましたが、まず@uasiさんから頂いたコメントの型推論の中の「3つバリエーション」を読むことをお勧めします。
#################################################
先だって、Qiitaやteratailで関数型について質問したところ、三者三様の回答をいただきました。
よくよく見てみると型推論をどこまで(どのように)適用するかの違いと気づきました。そこで考えられるだけの事例を総当たりで試してみました。
以下のコードを調べてみて、私自身では傾向がつかめたのですが、文書にまとめられませんでした。以下に張り付けたコードは、違いが分かりやすいようにコードを折り返すことなく列挙して配置していますので、横長になり画面からはみ出して見づらくなっています。もし、興味のある方は、intelliJなどのIDEにコピーしてコメントアウトを外して御確認ください。
以下のコードでコメントアウト(//)している個所は、エラーが出たコードです。その他のコードは同じ結果が得られます。(なお、このコードは、Map型で与えられた文字列(キー)と数値(バリュー)のペアを入れ替え数値をキー、文字列をバリューに組み替えたものを出力します。)
但し、ダブルコメントアウト(////)した部分は、@uasiさんにコメントを頂いた箇所を修正しました。(所謂、バグを埋め込んだ例です。この辺りも教訓として御覧いただければ、、、)コメントアウトせず残っているコードは、次のチェックを掛けてtrueを得ています。もし、型推論の使い方など誤りがあれば、ぜひご指摘ください。
println( flipValues00(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane") )
一番関数型らしい記述は、@ttatsfさんに教えていただいた、最後の方のflipValue98だと思います。
package FV3
fun main() {
val gradesByStudentA = mapOf("Josh" to 4.0, "Alex" to 2.0, "Jane" to 3.0)
println(gradesByStudentA)
val flipValues00 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
val flipValues01 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
val flipValues02 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
//// val flipValues03 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
//// val flipValues04 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
//// val flipValues05 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues06 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues07 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues08 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
// val flipValues09 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues10 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues11 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
val flipValues12 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
val flipValues13 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() } // flipValues13の後ろのgradesByStudentBと、= {の後ろのgradesByStudentBは、別の変数である。
val flipValues14 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues15 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues16 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues17 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues18 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues19 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues20 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues21 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues22 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues23 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() }
val flipValues24 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() } //flipValues12と同じ形式
val flipValues25 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() } //flipValues13と同じ形式
val flipValues26 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC : Map<String, Double> -> gradesByStudentC .map { it.value to it.key }.toMap() } //flipValues14と同じ形式
val flipValues30 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentA .map { it.value to it.key }.toMap() }
val flipValues31 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentA .map { it.value to it.key }.toMap() }
val flipValues32 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentA .map { it.value to it.key }.toMap() }
////val flipValues33 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues34 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues35 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues36 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues37 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues38 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
// val flipValues39 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues40 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues41 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentB .map { it.value to it.key }.toMap() }
val flipValues42 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentB .map { it.value to it.key }.toMap() }
val flipValues43 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentB .map { it.value to it.key }.toMap() }
val flipValues44 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues45 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues46 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues47 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues48 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues49 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues50 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues51 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues52 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentC .map { it.value to it.key }.toMap() }
// val flipValues53 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB -> gradesByStudentC .map { it.value to it.key }.toMap() }
val flipValues54 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentC .map { it.value to it.key }.toMap() }
val flipValues55 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentC .map { it.value to it.key }.toMap() }
val flipValues56 : ( gradesByStudentC : Map<String, Double>) -> Map<Double, String> = { gradesByStudentC -> gradesByStudentC .map { it.value to it.key }.toMap() }
val flipValues70 = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
////val flipValues71 = { gradesByStudentB : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
// val flipValues72 = { gradesByStudentA : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
val flipValues73 = { gradesByStudentB : Map<String, Double> -> gradesByStudentB .map { it.value to it.key }.toMap() }
////val flipValues80 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
////val flipValues81 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentA .map { it.value to it.key }.toMap() } // バグを埋め込んでいる例 @uasiさんコメント参照
// val flipValues82 : ( gradesByStudentA : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues83 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = { gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues84 : ( gradesByStudentB : Map<String, Double>) -> Map<Double, String> = gradesByStudentA .map { it.value to it.key }.toMap()
// val flipValues90 = { gradesByStudentA .map { it.value to it.key }.toMap() }
// val flipValues91 = { gradesByStudentB .map { it.value to it.key }.toMap() }
// val flipValues92 : ( gradesByStudentA ) = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
// val flipValues93 : ( gradesByStudentA : Map<String, Double>) = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
// val flipValues94 : ( gradesByStudentA : -> Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
// val flipValues95 : ( gradesByStudentA : Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
// val flipValues96 : ( gradesByStudentA Map<Double, String> = { gradesByStudentA : Map<String, Double> -> gradesByStudentA .map { it.value to it.key }.toMap() }
val flipValues97 : ( Map<String, Double>) -> Map<Double, String> = { gradesByStudentA .map { it.value to it.key }.toMap() }
val flipValues98 : (Map<String, Double>) -> Map<Double, String> = { it .map { it.value to it.key }.toMap() }
println("flipValue00:${flipValues00(gradesByStudentA)}")
println(flipValues00(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue01:${flipValues01(gradesByStudentA)}")
println(flipValues01(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue02:${flipValues02(gradesByStudentA)}")
println(flipValues02(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
////println("flipValue03:${flipValues03(gradesByStudentA)}")
////println(flipValues03(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
////println("flipValue04:${flipValues04(gradesByStudentA)}")
////println(flipValues04(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
////println("flipValue05:${flipValues05(gradesByStudentA)}")
////println("flipValue06:${flipValues06(gradesByStudentA)}")
////println("flipValue07:${flipValues07(gradesByStudentA)}")
////println("flipValue08:${flipValues08(gradesByStudentA)}")
// println("flipValue09:${flipValues09(gradesByStudentA)}")
// println("flipValue10:${flipValues10(gradesByStudentA)}")
// println("flipValue11:${flipValues11(gradesByStudentA)}")
println("flipValue12:${flipValues12(gradesByStudentA)}")
println(flipValues12(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue13:${flipValues13(gradesByStudentA)}")
println(flipValues13(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue14:${flipValues14(gradesByStudentA)}")
println(flipValues14(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
// println("flipValue15:${flipValues15(gradesByStudentA)}")
// println("flipValue16:${flipValues16(gradesByStudentA)}")
// println("flipValue17:${flipValues17(gradesByStudentA)}")
// println("flipValue18:${flipValues18(gradesByStudentA)}")
// println("flipValue19:${flipValues19(gradesByStudentA)}")
// println("flipValue20:${flipValues20(gradesByStudentA)}")
// println("flipValue21:${flipValues21(gradesByStudentA)}")
// println("flipValue22:${flipValues22(gradesByStudentA)}")
// println("flipValue23:${flipValues23(gradesByStudentA)}")
println("flipValue24:${flipValues24(gradesByStudentA)}")
println(flipValues24(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue25:${flipValues25(gradesByStudentA)}")
println(flipValues25(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue26:${flipValues26(gradesByStudentA)}")
println(flipValues26(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue30:${flipValues30(gradesByStudentA)}")
println(flipValues30(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue31:${flipValues31(gradesByStudentA)}")
println(flipValues31(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue32:${flipValues32(gradesByStudentA)}")
println(flipValues32(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
////println("flipValue33:${flipValues33(gradesByStudentA)}")
////println("flipValue34:${flipValues34(gradesByStudentA)}")
////println("flipValue35:${flipValues35(gradesByStudentA)}")
////println("flipValue36:${flipValues36(gradesByStudentA)}")
////println("flipValue37:${flipValues37(gradesByStudentA)}")
////println("flipValue38:${flipValues38(gradesByStudentA)}")
// println("flipValue39:${flipValues39(gradesByStudentA)}")
// println("flipValue40:${flipValues40(gradesByStudentA)}")
// println("flipValue41:${flipValues41(gradesByStudentA)}")
println("flipValue42:${flipValues42(gradesByStudentA)}")
println(flipValues42(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue43:${flipValues43(gradesByStudentA)}")
println(flipValues43(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue44:${flipValues44(gradesByStudentA)}")
println(flipValues44(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
// println("flipValue45:${flipValues45(gradesByStudentA)}")
// println("flipValue46:${flipValues46(gradesByStudentA)}")
// println("flipValue47:${flipValues47(gradesByStudentA)}")
// println("flipValue48:${flipValues48(gradesByStudentA)}")
// println("flipValue49:${flipValues49(gradesByStudentA)}")
// println("flipValue50:${flipValues50(gradesByStudentA)}")
// println("flipValue51:${flipValues51(gradesByStudentA)}")
// println("flipValue52:${flipValues52(gradesByStudentA)}")
// println("flipValue53:${flipValues53(gradesByStudentA)}")
println("flipValue54:${flipValues54(gradesByStudentA)}")
println(flipValues54(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue55:${flipValues55(gradesByStudentA)}")
println(flipValues55(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue56:${flipValues56(gradesByStudentA)}")
println(flipValues56(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
// println("flipValue57:${flipValues57(gradesByStudentA)}")
// println("flipValue58:${flipValues58(gradesByStudentA)}")
// println("flipValue59:${flipValues59(gradesByStudentA)}")
// println("flipValue60:${flipValues60(gradesByStudentA)}")
// println("flipValue61:${flipValues61(gradesByStudentA)}")
// println("flipValue62:${flipValues62(gradesByStudentA)}")
// println("flipValue63:${flipValues63(gradesByStudentA)}")
// println("flipValue64:${flipValues64(gradesByStudentA)}")
// println("flipValue65:${flipValues65(gradesByStudentA)}")
// println("flipValue66:${flipValues66(gradesByStudentA)}")
// println("flipValue67:${flipValues67(gradesByStudentA)}")
// println("flipValue68:${flipValues68(gradesByStudentA)}")
// println("flipValue69:${flipValues69(gradesByStudentA)}")
println("flipValue70:${flipValues70(gradesByStudentA)}")
println(flipValues70(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
////println("flipValue71:${flipValues71(gradesByStudentA)}")
// println("flipValue72:${flipValues72(gradesByStudentA)}")
println("flipValue73:${flipValues73(gradesByStudentA)}")
println(flipValues73(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
// println("flipValue74:${flipValues74(gradesByStudentA)}")
// println("flipValue75:${flipValues75(gradesByStudentA)}")
// println("flipValue76:${flipValues76(gradesByStudentA)}")
// println("flipValue77:${flipValues77(gradesByStudentA)}")
// println("flipValue78:${flipValues78(gradesByStudentA)}")
// println("flipValue79:${flipValues79(gradesByStudentA)}")
////println("flipValue80:${flipValues80(gradesByStudentA)}")
////println("flipValue81:${flipValues81(gradesByStudentA)}")
// println("flipValue82:${flipValues82(gradesByStudentA)}")
// println("flipValue83:${flipValues83(gradesByStudentA)}")
// println("flipValue84:${flipValues84(gradesByStudentA)}")
// println("flipValue85:${flipValues85(gradesByStudentA)}")
// println("flipValue86:${flipValues86(gradesByStudentA)}")
// println("flipValue87:${flipValues87(gradesByStudentA)}")
// println("flipValue88:${flipValues88(gradesByStudentA)}")
// println("flipValue89:${flipValues89(gradesByStudentA)}")
// println("flipValue90:${flipValues90(gradesByStudentA)}")
// println("flipValue91:${flipValues91(gradesByStudentA)}")
// println("flipValue92:${flipValues92(gradesByStudentA)}")
// println("flipValue93:${flipValues93(gradesByStudentA)}")
// println("flipValue94:${flipValues94(gradesByStudentA)}")
// println("flipValue95:${flipValues95(gradesByStudentA)}")
// println("flipValue96:${flipValues95(gradesByStudentA)}")
println("flipValue97:${flipValues97(gradesByStudentA)}")
println(flipValues97(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
println("flipValue98:${flipValues98(gradesByStudentA)}")
println(flipValues98(mapOf("Tom" to 9.0)) != mapOf(4.0 to "Josh", 2.0 to "Alex", 3.0 to "Jane"))
// println("flipValue99:${flipValues99(gradesByStudentA)}")
}