Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kotlin/Program3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Write a program to filter number from list in kotlin
19 changes: 19 additions & 0 deletions kotlin/Program3/filterList.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
fun main(args: Array<String>) {
println("Basic Filter List Function")
val numbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
val odd = numbers.filter { it % 2 != 0 }
val even = numbers.filter { it % 2 == 0 }
val moreThan10 = numbers.filter { it > 10 }

println("odd: $odd")
println("even: $even")
println("moreThan10: $moreThan10")

val listDay= listOf("Senin","Selasa","Senin","Kamis","Jumat","Sabtu","Minggu")
val containsS = listDay.filter { it.contains("s") }
val equal = listDay.filter { it == "Selasa" }
val length = listDay.filter { it.length > 5 }
println("contains S: $containsS")
println("equal: $equal")
println("length: $length")
}
3 changes: 2 additions & 1 deletion kotlin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| Program No.| Question |
| ------- | ------ |
| [Program-1](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/kotlin/Program1/pattern.kt) | Write a program to print half pyramid using ' * '
| [Program-2](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/kotlin/Program2/extension.kt) | Q2. Write a program to plus and minus with sample of extension function from kotlin
| [Program-2](https://github.com/swaaz/basicprograms/blob/master/kotlin/Program2/extension.kt) | Q2. Write a program to plus and minus with sample of extension function from kotlin
| [Program-3](https://github.com/swaaz/basicprograms/blob/master/kotlin/Program3/filterList.kt) | Write a program to filter number from list in kotlin

</div>