fun List.customAppend(list: List): List { val result = mutableListOf() result.addAll(this) result.addAll(list) return result } fun List>.customConcat(): List { val result = mutableListOf() forEach { result.addAll(it) } return result } fun List.customFilter(predicate: (T) -> Boolean): List { val result = mutableListOf() forEach { if (predicate(it)) { result.add(it) } } return result } val List.customSize: Int get() = size fun List.customMap(transform: (T) -> U): List { val result = mutableListOf() forEach { result.add(transform(it)) } return result } fun List.customFoldLeft(initial: U, f: (U, T) -> U): U { if (isEmpty()) return initial return drop(1).customFoldLeft(f(initial, first()), f) } fun List.customFoldRight(initial: U, f: (T, U) -> U): U { if (isEmpty()) return initial return f(first(), drop(1).customFoldRight(initial, f)) } fun List.customReverse(): List { val result = mutableListOf() forEach { result.add(0, it) } return result }