# Some suggestions of standard library functions

**URL:** <https://discuss.kotlinlang.org/t/some-suggestions-of-standard-library-functions/715>\
**Category:** Uncategorized\
**Created:** [November 3, 2013, 9:22am UTC](https://discuss.kotlinlang.org/t/some-suggestions-of-standard-library-functions/715 "2013-11-03T09:22:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehanizator](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/mehanizator/32/1584_2.png) [@mehanizator](https://discuss.kotlinlang.org/u/mehanizator)\
**Post date:** [November 3, 2013, 9:22am UTC](https://discuss.kotlinlang.org/t/some-suggestions-of-standard-library-functions/715/1 "2013-11-03T09:22:19Z")

</div>

Hello everyone,

I’ve recently started to use Kotlin and I have some things that force me to write extension functions.

1. There’s no standard library function to transform a collection of pairs into map. I can write val m = mapOf(\*listOfPairs.copyToArray()), but it looks like a hack. It would be nice to have fun Iterable\<Pair\<T,V\>\>.toMap(): Map\<T, V\> in standard library.

2. I cannot write someMap.map { key, value -\> … }, which would be nice also.

3. Analog of Scala’s “sf” string pattern (with printf formatting) would be VERY appreciated.

4. Using IDEA with Java I got used to write right part of expression, than hit Alt-Enter “Introduce local variable”, I was suprised this is not yet implemented in Kotlin plugin. It’s no big deal, but it breaks my coding pattern 🙂

5. In java I can take some code in brakets to make all variable names local, why I cannot do this in Kotlin?

Thank you!

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [November 5, 2013, 11:26am UTC](https://discuss.kotlinlang.org/t/some-suggestions-of-standard-library-functions/715/2 "2013-11-05T11:26:35Z")

</div>

> 1. There's no standard library function to transform a collection of pairs into map. I can write val m = mapOf(\*listOfPairs.copyToArray()), but it looks like a hack. It would be nice to have fun Iterable\<Pair\<T,V\>\>.toMap(): Map\<T, V\> in standard library.
> 
> 1.

Contributions to the standard library are very welcome. Also feel free to file an issue in [http://youtrack.jetbrains.net/issues/KT](http://youtrack.jetbrains.net/issues/KT)

> 3. Analog of Scala's "sf" string pattern (with printf formatting) would be VERY appreciated.

Yes, it would be nice to have it, feel free to file an iisue.

> 4. Using IDEA with Java I got used to write right part of expression, than hit Alt-Enter "Introduce local variable", I was suprised this is not yet implemented in Kotlin plugin. It's no big deal, but it breaks my coding pattern :)

We should support Alt+Enter as well, but for now we only do it throgh explicit "Introduce variable" refactoring (Alt+Ctrl+V). Again, feel free to file an issue

> 5. In java I can take some code in brakets to make all variable names local, why I cannot do this in Kotlin?

Use the run() function:

```kotlin
run {
  val foo = "this is local"
  println(foo)
}
```
