diff --git a/task/.gitignore b/task/.gitignore new file mode 100644 index 0000000..3ddbf4c --- /dev/null +++ b/task/.gitignore @@ -0,0 +1,32 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Kotlin ### +.kotlin + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/task/.idea/.gitignore b/task/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/task/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/task/.idea/inspectionProfiles/Project_Default.xml b/task/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..df543e3 --- /dev/null +++ b/task/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/task/.idea/kotlinc.xml b/task/.idea/kotlinc.xml new file mode 100644 index 0000000..cba7a76 --- /dev/null +++ b/task/.idea/kotlinc.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/task/.idea/libraries/KotlinJavaRuntime.xml b/task/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..3e6dc71 --- /dev/null +++ b/task/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/task/.idea/misc.xml b/task/.idea/misc.xml new file mode 100644 index 0000000..f03c948 --- /dev/null +++ b/task/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/task/.idea/modules.xml b/task/.idea/modules.xml new file mode 100644 index 0000000..52cbedd --- /dev/null +++ b/task/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/task/.idea/vcs.xml b/task/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/task/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/task/src/Main.kt b/task/src/Main.kt new file mode 100644 index 0000000..930f0d1 --- /dev/null +++ b/task/src/Main.kt @@ -0,0 +1,56 @@ + +fun filterNames(names: List, condition: (String) -> Boolean): List { + return names.filter(condition) +} +fun customFilter(numbers: List, filter: (Int) -> Boolean): List { + return numbers.filter(filter) +} + +fun processNumbers(number: List): List { + val filteredNumbers = number.filter { it % 2 != 0 } + + val squaredNumbers = filteredNumbers.map { it * it } + + return squaredNumbers +} +//fun processNumbers1( +// number: List, +// filter: (Int) -> Boolean, +// transform: (Int) -> Int +//): List { +// return number.filter(filter).map(transform) +//} + +val numbers = listOf(1,2,3,4,5,6,7,8,9,10) +val words = listOf("apple", "banana", "kiwi", "strawberry", "grape") + +fun main() { + val doubleNumbers = numbers.map { it * 2 } + + println(doubleNumbers) + + val names = listOf("Alice", "Bob", "Amir", "Charlie", "Annie", "David") + + val filteredNames = filterNames(names) { it.startsWith("A") } + println(filteredNames) + + val sortedWords = words.sortedByDescending { it.length } + println(sortedWords) + + val numbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + + val greaterThanFive = customFilter(numbers) { it > 5 } + println("Numbers greater than 5: $greaterThanFive") + + val evenNumbers = customFilter(numbers) { it % 2 == 0 } + println("Even numbers: $evenNumbers") + + val multiplesOfThree = customFilter(numbers) { it % 3 == 0 } + println("Multiples of 3: $multiplesOfThree") + + val number = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + + val result = processNumbers(number) + + println(result) +} \ No newline at end of file diff --git a/task/task.iml b/task/task.iml new file mode 100644 index 0000000..43dd653 --- /dev/null +++ b/task/task.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file