2017 PSLE Math Question

Answer: 10 (Yes!) but why ?

…(see explanation here )


Advanced Kotlin Education

Kotlin’s real power is to explore its Functional Programming features, besides the “cosmetic” improvement of concise codes to avoid Java’s annoying boilerplates.

Note: https://www.raywenderlich.com/173352/raywenderlich-com-goes-kotlin-and-needs-tech-editors

* Level of difficulty (* = Simple, ** = Medium, *** = Difficult)

0. What is Functional Programming ?

This Romanian IT expert introduces us to Functional Programming (FP). He has the advices:
1) No need to know deep Category Theory (CT)- but nice to know little bit. (In Romania, the students learn CT in Grade-12 (equivalent JC2);
2) Haskell is the lingua franca of FP. Learn it to understand most FP concepts, even if you later use other FP languages (Kotlin, Scala);
3) Dynamic Type languages (Lisp, Clojure) are not good, because only Static type (eg. Kotlin, Java with “final”) can ensure Immutability which is the essence of FP;


1. Sequence over Collection, Sealed Class, Object => new Class


2. Function Literal (Lambda Expression) (**)


3. “Either” Monad (**)


4. Kotlin “DI” Dependency Injection – the “Reader” Monad vs Java Dagger: (***)

View story at Medium.com

5. Function Memoization (**)

View story at Medium.com

6. Remove all ugly “!!” with these 6 Kotlin techniques (*)


7. Generic Extension Function (aka Polymorphism) (**)


8. Co-routine (Weather app demo) (***)


9. Free Monads (***)


10. Free monoids and Free Monads (***) – (in Scala codes)


11. Operator Overloading (Antonio’s Chap 11) *


12. Android UI Fragments in Kotlin


13. Design Patterns in Kotlin


14. Static Method (Companion Object)


Kotlin 1.2 Multi-Platform Project

This language feature of writing only once and run on many platform was promised by Java in 1999 through JVM.

Kotlin, a successor of Java supported officially by Google since May 2017, goes further than Java on ambitious multi-platform, not only through Android’s Delvick JVM (a modified version of Oracle’s JVM), also on JavaScript engine (in supported browsers), and compiled to (future) native codes on Microsoft Windows…


Kotlin 1.2 Beta Release 30/9/2017:


Zhihu 知乎: 环Ring, 域Field, (半Semi-)群Group, 幺半群 MonoId



(I) 环和域
环 (Ring) 是德文, 这名词是David Hilbert发明的。
“环”最好的例子: 整数(Integer) 记作 Z (德文Zahl) 是个环。 他研究 Clock Arithmetic 时钟 是个 Modular Arithmetic (Mod 12)运算, 比如 15 = 3 mod 12

钟表上的整数 Z 数字 排成 一个钟的环状, 故称 此数是 “Zahl Ring” 整数 “环”。

Hilbert 的得意女弟子 Emile Noether 把 环论 发扬光大, 创造 “Noether Ring”。

如果 把 “12” 变成 任一素数 p , “环”就升级成”域” (Field) – 除了有环的( + – *) 运算, 还可以 (÷)。

Hilbert 发现 “环”有个重要性质是含有 “理想” (Ideal) – 理想 * 任何”外面”的东西 还回来”里面”。
例子: Z Ring 里有 “0”, 2Z, nZ…
0 * 任何Z数 => 回来 “0家族里面”
偶数 2 * 任何Z数 => 回来” 偶数 (2Z)家族里面”

大名鼎鼎的中国古代算术”韩信点兵”就是 含有 “环 和理想”的理论。

(II) 群 Group / 半群 Semi-Group / 幺半群MonoId
Group 群 有4个性质 C.A.N.I.
C: Close 封闭性
A: Associative 连续性
N: Neutral (or Identity = Id) 幺元
I: Inverse 逆元

Semi-Group 半群 只有2个性质: C.A.

Monoid 么半群 : C.A. + N (= Id) => Mono + Id