# Using transformations for sequences with flows?

**URL:** <https://discuss.kotlinlang.org/t/using-transformations-for-sequences-with-flows/18733>\
**Category:** Support\
**Created:** [August 10, 2020, 8:56pm UTC](https://discuss.kotlinlang.org/t/using-transformations-for-sequences-with-flows/18733 "2020-08-10T20:56:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![radekm](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/radekm/32/7733_2.png) [@radekm](https://discuss.kotlinlang.org/u/radekm)\
**Post date:** [August 10, 2020, 8:56pm UTC](https://discuss.kotlinlang.org/t/using-transformations-for-sequences-with-flows/18733/1 "2020-08-10T20:56:41Z")

</div>

Hi,

is it possible to use transformations for sequences with flows?

Because sequences have much more transformations than flows. So I would love to use those transformations on flows.

So is there some function which allows me to do it? Eg:

```kotlin
fun <A, B> Flow<A>.transformUsingSequence(f: (Sequence<A>) -> Sequence<B>): Flow<B>

```

Sample usage:

```kotlin
// Since chunked doesn't exist for flows, we use version for sequences.
val newFlow = myFlow.transformUsingSequence { it.chunked(10) }

```

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [August 11, 2020, 5:30am UTC](https://discuss.kotlinlang.org/t/using-transformations-for-sequences-with-flows/18733/2 "2020-08-11T05:30:50Z")

</div>

I do not think it is possible to do it directly. The sequence could be converted to Flow, but Flow could not be in general converted to Sequence without losing Flow semantics. Probably it is possible to do something with complicated scope compositions, but it is much better to replicate the required sequence functions for Flow.
