Mathematicians crack the cursed curve

The mathematicians proved there are ONLY 7 solutions.


Xamarine -Microsoft Cross-Platform Mobile Apps Developer Tool

Xamarine is based on MS Visual Studio to build both IOS and Android Mobile apps with the same codes in C#.

Caveat is the language is C#, slightly less verbose than Java, not functional programming like Kotlin or Scala.

Explore Xamarine / C# if you are from the old Object-Oriented school of programming.

If you are a Mac user, then sorry Xamarine/Visio Studio/.Net / C# only run on PC Windows.

Gang Of Four O-O Patterns vs Functional Programming Styles

Object-Oriented (O-O) Software Design follows the Gang Of Four (GOF) best practice Design Patterns (which borrow the concept of Architecture “Template” Design Patterns).

“Objects use Patterns, Functions use Styles (aka Monads) .”

“四人帮” Gang of Four (GoF) Object-Oriented vs Functional Programming (FP):

My analogies of O-O vs FP:

1. Kungfu (or any “hard” martial arts) vs Taiji (“Soft” Chi-based “气” style as demonstrated by Jack Ma in the video below) :

2. Western Alphabet-based Words (long chain of letters, long bytes) vs Chinese Ideogram-based Words (short, less bytes).
Eg. “Software” (8 bytes) = “软件” (2× double-bytes = 4 bytes)


  1. Java & Android practice GoF patterns, making the software on one hand well designed, on the other hand over lengthy and over complicated for the sake of following the GoF patterns.
  2. The Functional Programming “FP” design which is based on Functions, rather than Objects (as in O-O), should avoid the GoF patterns but pure FP spirit – Monadic Design (Monad I/O, Monad Reader, Apply, Reduce, Map, Flatmap, etc).
  3. Kotlin is a hybrid of O-O and FP. In order to be convertible to Java codes on Android platform, GoF pattern is often used a la Java style though coded in Kotlin. (
  4. This is in contrast to another hybrid OO-FP language (also a JVM language like Kotlin & Java) Scala which adopts the pure FP elegance.

Below are some common GoF O-O patterns :

1. Factory Pattern

2. Observer Pattern (Subscribe-Publish)

3. Strategy Pattern (ConditionalInterface”)

4. Singleton Pattern 单枪走天下 Object with 1 and only 1 instance <=> “Compound Object” (in Kotlin)


1. Functional Kotlin

2. SICP: Sequence as conventional interfaces: eg. flatmap, map, reduce, fold

3. Do not fear Monads:

4. OO vs FP?

Lambda Calculus – The Math Behind Functional Programming

Functional Programming (FP) Languages : Lisp, Haskell, Scala, Kotlin, etc.

Other non-FP influenced by Lambda Calculus: Python, Ruby, Javascript, Java 8, C++

Inventor of Lambda Calculus : Alonzo Church (1903 – 1995), whose student in Princeton University (1936-1938) was Alan Turing (The Father of Artificial Intelligence).

Lambda Calculus is not : another Differential Calculus !

Note: Calculus has a meaning of manipulating symbolic expressions : either in functions (differentiation, integration) or computations.

Lambda Calculus is almost programming!

I. Syntax of Lambda Calculus: \boxed {\lambda \text { param . body }}

eg. \lambda \: x \: . \: x + 1

Notice: it has only one parameter “x”.

  1. Function definition: \lambda
  2. Identifier reference: x
  3. Function application: x + 1

II. Currying 柯里化 : (named after Haskell Curry ) for multiple parameters.

eg. \lambda \: x \: . \: (\lambda \: y \: . \: x + y)

written by “Currying” as : \boxed { \lambda \: x \: y \: . \: x + y}

Syntactic Sugar 语法糖 : a notational shorthand. Eg. “cubic”
cubic = λ x . x * x * x

III. Binding: Every parameter (aka variable) must be declared (syntactically binding).

eg. \lambda \: x \: . \: z x

here, x is bound, but z is FREE (error!)

IV. Two Execution Methods:

1. \alpha \text{ conversion }

  • rename variables to avoid conflict

2. \beta \text{ reduction} \text { - Apply a function}

  • Eager evaluation strategy : Right to Left (innermost expression first to outermost) or
  • Lazy evaluation strategy : Left to Right (outermost expression first to innermost) – don’t compute the value of an expression until you need to – (save memory space and computing time)
  • Most FP are Lazy.
  • Most Procedural (Imperative) languages (C, Fortran, Basic, …) are Eager.

V. Lambda Calculus fulfilling the 3 conditions for “Turing Complete” Computation :

  • UnboundedStorage” (not necessarily a physical device) – generate arbitrarily complicated values in a variable or many functions without bound.
  • Arithmetic – Church numerals (Peano arithmetic using functions): eg z=0, s= z+ 1 => 1 = λ s z . s z => 2 = λ s z . s ( s z ) … => 7= λ s z . s (s(s(s(s(s(s(z )))))))
  • Control Flow – TRUE = λ t f . t / FALSE = λ t f . f / BoolAnd = λ x y . x y FALSE / BoolOr = λ x y . x TRUE y / Repetition by Recursion (Y Combinator )

Conclusion: Lambda Calculus = “Computer on paper”

VI. Type – Consistent Model (notation “:“)

eg. λ x : I . x + 3 ( I is Integer Type)

=> The result (x + 3) is also Type I since by inference “+” is of Type I -> I

Reference: “Good Math” by Mark Chu-Carroll

Explore Kotlin’s Advanced Functional Programming

Since May 2017 Kotlin released by Google, 12.8% Java developers have converted to Kotlin, yet they still keep to the OO spirit of Java (for Interoperability) , not taking full advantage of FP capability of Kotlin. The OO Design Patterns of Android Java still being used instead of the FP more elegant “Monadic” Design.

1. Interview with Kotlin Designer:

2. Android Studio 3.0 Released :

2a. Android Studio v3.0 with Kotlin built-in & many improvements.

(The previous stable v2.3 needs seperate Kotlin plug-in)

2c: Gradle upgrade

3. Inner / Infix Function

4. Test (Mockito)

Kluent library:

5. Function vs Procedure vs MethodKotlin simplifies all 3 into 1 : Function which always returns a value or UNIT.

View story at

6. Kotlin has which Java lacks … “with“, “?”, …

7. Kotlin Operator Overloading aka “Convention”: ‘plus’ / ‘+’

8. JVM Byte Code Generation:

9. Reified Types

10. SICP: Sequence as conventional interfaces: eg. flatmap, map, reduce, fold


12. Generic : Kotlin入门(11)江湖绝技之特殊函数

13. Array <String>: Kotlin入门(4)声明与操作数组

14. ViewPager (Horizontal Swipe)

15. Kotlin 1.2 Beta & Multiplatform iOS

16. Kotlin Edu ( Android Studio 3.0)

17. Kotlin Style Guide

18. Android Layout FoundamentalConstraintLayout

19. Android SDK

20. Javalin v1.0 – Web Framework for Java + Kotlin

21. Ten Modern Features (Kotlin, Clojure, Javascript, Swift…)

View story at

22. Function literals with receiver

23. Sealed classes: (restricted types no “else”)

24. Android Intent

25. Top kotlin tutorials

View story at

26. Kotlin Contexts & Shared Preferences

27. Delegation – but not Inheritance (which takes all)

28. Functions or Properties Reference (cool *)

View story at

29. Web Framework ktor: