From the course: Kotlin for Android: Best Practices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Functional programming: map, reduce

Functional programming: map, reduce - Kotlin Tutorial

From the course: Kotlin for Android: Best Practices

Start my 1-month free trial

Functional programming: map, reduce

- [Instructor] Let's take a look at this program. I have three checkboxes with custom backgrounds, so that when you check it, it's an unbroken line, and when you uncheck it, it's a broken line. These three lines form a trigram, which are used in the book of I Ching. What I want is when I change these lines, the text view underneath will display the name of the corresponding trigram. Let's take a look at the app itself. I have set up most of it already. On line nine, I have defined the variable trigram which is a hashmap from the string for example one zero zero to the name of the trigram. It is wrapped under by lazy because I don't necessarily need to instantiate it until it's used. Then in oncreate, I have set up line one, line two, line three, the three checkboxes so that whenever someone clicks on it, the update function is called. And finally, on line 33, I have the update function, which currently just sets the text to, todo. Let's use functional programming to change this text…

Contents