Skip to content

Commit 0290ba5

Browse files
committed
added kotlin implementation
1 parent 1663c23 commit 0290ba5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

fp.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
fun increment(n: Int): Int {
2+
return n + 1
3+
}
4+
5+
fun myObjective(arr: IntArray, f: (input: Int) -> Int) {
6+
for (i in 0 until arr.size)
7+
arr[i] = f(arr[i])
8+
}
9+
10+
fun main() {
11+
var arr: IntArray = intArrayOf(0, 1, 2, 3, 4)
12+
myObjective(arr, ::increment)
13+
14+
for (i in 0 until arr.size)
15+
print("${arr[i]} ")
16+
}

0 commit comments

Comments
 (0)