Kotlin Is there a way to flatten Map<K out T , List to List
I would like to transform the Map to List
e.g I have
mapOf("a" to listOf(1,2),
"b" to listOf(3,4)
)
I want the result to be
listOf("a", 1, 2, "b", 3, 4)
order must be Key and its Values, Key and its Values, ...
is there some function in kotlin that could help me with that?
kotlin
add a comment |
I would like to transform the Map to List
e.g I have
mapOf("a" to listOf(1,2),
"b" to listOf(3,4)
)
I want the result to be
listOf("a", 1, 2, "b", 3, 4)
order must be Key and its Values, Key and its Values, ...
is there some function in kotlin that could help me with that?
kotlin
4
there is no way that you ever get such a list out of that map. The reason is, that when you create the map this way you actually get a map containing:"a"
with2
and"b"
with value4
. Otherwise: yes... you can flatten it... maybe with something like:mapOf(...).flatMap { (string, int) -> listOf(string, int) }
or similar...map.flatMap { (string, ints) -> listOf(string).plus(ints) }
– Roland
Nov 20 '18 at 12:46
@Roland sorry my bad, I updated question. Yourmap.flatMap { (string, ints) -> listOf(string).plus(ints) }
works well for me. thanks
– svkaka
Nov 20 '18 at 15:15
add a comment |
I would like to transform the Map to List
e.g I have
mapOf("a" to listOf(1,2),
"b" to listOf(3,4)
)
I want the result to be
listOf("a", 1, 2, "b", 3, 4)
order must be Key and its Values, Key and its Values, ...
is there some function in kotlin that could help me with that?
kotlin
I would like to transform the Map to List
e.g I have
mapOf("a" to listOf(1,2),
"b" to listOf(3,4)
)
I want the result to be
listOf("a", 1, 2, "b", 3, 4)
order must be Key and its Values, Key and its Values, ...
is there some function in kotlin that could help me with that?
kotlin
kotlin
edited Nov 20 '18 at 15:33
svkaka
asked Nov 20 '18 at 12:39
svkakasvkaka
783421
783421
4
there is no way that you ever get such a list out of that map. The reason is, that when you create the map this way you actually get a map containing:"a"
with2
and"b"
with value4
. Otherwise: yes... you can flatten it... maybe with something like:mapOf(...).flatMap { (string, int) -> listOf(string, int) }
or similar...map.flatMap { (string, ints) -> listOf(string).plus(ints) }
– Roland
Nov 20 '18 at 12:46
@Roland sorry my bad, I updated question. Yourmap.flatMap { (string, ints) -> listOf(string).plus(ints) }
works well for me. thanks
– svkaka
Nov 20 '18 at 15:15
add a comment |
4
there is no way that you ever get such a list out of that map. The reason is, that when you create the map this way you actually get a map containing:"a"
with2
and"b"
with value4
. Otherwise: yes... you can flatten it... maybe with something like:mapOf(...).flatMap { (string, int) -> listOf(string, int) }
or similar...map.flatMap { (string, ints) -> listOf(string).plus(ints) }
– Roland
Nov 20 '18 at 12:46
@Roland sorry my bad, I updated question. Yourmap.flatMap { (string, ints) -> listOf(string).plus(ints) }
works well for me. thanks
– svkaka
Nov 20 '18 at 15:15
4
4
there is no way that you ever get such a list out of that map. The reason is, that when you create the map this way you actually get a map containing:
"a"
with 2
and "b"
with value 4
. Otherwise: yes... you can flatten it... maybe with something like: mapOf(...).flatMap { (string, int) -> listOf(string, int) }
or similar... map.flatMap { (string, ints) -> listOf(string).plus(ints) }
– Roland
Nov 20 '18 at 12:46
there is no way that you ever get such a list out of that map. The reason is, that when you create the map this way you actually get a map containing:
"a"
with 2
and "b"
with value 4
. Otherwise: yes... you can flatten it... maybe with something like: mapOf(...).flatMap { (string, int) -> listOf(string, int) }
or similar... map.flatMap { (string, ints) -> listOf(string).plus(ints) }
– Roland
Nov 20 '18 at 12:46
@Roland sorry my bad, I updated question. Your
map.flatMap { (string, ints) -> listOf(string).plus(ints) }
works well for me. thanks– svkaka
Nov 20 '18 at 15:15
@Roland sorry my bad, I updated question. Your
map.flatMap { (string, ints) -> listOf(string).plus(ints) }
works well for me. thanks– svkaka
Nov 20 '18 at 15:15
add a comment |
3 Answers
3
active
oldest
votes
My second comment variant as answer for a Map<String, List<Int>>
:
mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
.flatMap { (key, values) -> listOf(key) + values }
which gives a List<Any>
with the keys followed by their values.
This example makes use of destructuring declaration and Map.flatMap
.
add a comment |
UPDATE: the answer below was written before the question was updated and changed how the map was created (see the history of the question for details). As the question now stands, the answer below will no longer work. It does work for the question as originally asked though, I believe.
@Roland is right that your map will never result in that list because there can only ever be a single value in the map against any given key. So I think you need to replace that map with a list of pairs. You can then group it and flatmap it to get your desired result:
val pairs = listOf("a" to 1, "a" to 2, "b" to 3, "b" to 4)
val result = pairs
.groupBy { it.first }
.flatMap { (key, values) -> listOf(key).plus(values.map { it.second }) }
Another slightly different option which you might decide is more readable is this:
val result = pairs
.groupBy({ it.first }, { it.second })
.flatMap { (key, values) -> listOf(key).plus(values) }
cool thanks, this one suits better to my original question.
– svkaka
Nov 20 '18 at 15:25
why do you group it first? we already have a map?
– Roland
Nov 20 '18 at 15:42
This answer was added before the question was updated. I'll add a comment on the answer to explain as you're right that, as the question now stands, the answer is no longer correct.
– Yoni Gibbs
Nov 20 '18 at 15:44
ah, ok... got it... thanks for the clarification..
– Roland
Nov 20 '18 at 15:47
add a comment |
You can flatMap
over map.entries
. Have a look at this function:
val map = mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
println(map)
val flattened : List<Any> = map.entries.flatMap {entry ->
//create list with key as only element, must be type <Any> to add other stuff later
val list = mutableListOf<Any>(entry.key)
//add values
list.addAll(entry.value)
list
}
println(flattened)
prints:
{a=[1, 2], b=[3, 4]}
[a, 1, 2, b, 3, 4]
@Rolands answer inspired this even simpler, more idiomatic version. It essentially does the same, but crams everything into one line:
val flattened: List<Any> = map.flatMap {entry ->
listOf(entry.key) + entry.value
}
thanks, this one is quite harder to read but works well
– svkaka
Nov 20 '18 at 15:36
1
Once you get used to functional programming it will be immediately clear what it does. I dont think it gets any simpler, if you want to preserve the order of the keys and values. In the link you also find a different version withfold
maybe you like that one better ;)
– leonardkraemer
Nov 20 '18 at 15:38
also thanks for the link to function :)
– svkaka
Nov 20 '18 at 15:42
Look at the update, maybe you'll find it easier.
– leonardkraemer
Nov 20 '18 at 15:47
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393182%2fkotlin-is-there-a-way-to-flatten-mapk-out-t-listv-out-t-to-listt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
My second comment variant as answer for a Map<String, List<Int>>
:
mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
.flatMap { (key, values) -> listOf(key) + values }
which gives a List<Any>
with the keys followed by their values.
This example makes use of destructuring declaration and Map.flatMap
.
add a comment |
My second comment variant as answer for a Map<String, List<Int>>
:
mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
.flatMap { (key, values) -> listOf(key) + values }
which gives a List<Any>
with the keys followed by their values.
This example makes use of destructuring declaration and Map.flatMap
.
add a comment |
My second comment variant as answer for a Map<String, List<Int>>
:
mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
.flatMap { (key, values) -> listOf(key) + values }
which gives a List<Any>
with the keys followed by their values.
This example makes use of destructuring declaration and Map.flatMap
.
My second comment variant as answer for a Map<String, List<Int>>
:
mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
.flatMap { (key, values) -> listOf(key) + values }
which gives a List<Any>
with the keys followed by their values.
This example makes use of destructuring declaration and Map.flatMap
.
edited Nov 20 '18 at 15:53
answered Nov 20 '18 at 15:37
RolandRoland
10.1k11241
10.1k11241
add a comment |
add a comment |
UPDATE: the answer below was written before the question was updated and changed how the map was created (see the history of the question for details). As the question now stands, the answer below will no longer work. It does work for the question as originally asked though, I believe.
@Roland is right that your map will never result in that list because there can only ever be a single value in the map against any given key. So I think you need to replace that map with a list of pairs. You can then group it and flatmap it to get your desired result:
val pairs = listOf("a" to 1, "a" to 2, "b" to 3, "b" to 4)
val result = pairs
.groupBy { it.first }
.flatMap { (key, values) -> listOf(key).plus(values.map { it.second }) }
Another slightly different option which you might decide is more readable is this:
val result = pairs
.groupBy({ it.first }, { it.second })
.flatMap { (key, values) -> listOf(key).plus(values) }
cool thanks, this one suits better to my original question.
– svkaka
Nov 20 '18 at 15:25
why do you group it first? we already have a map?
– Roland
Nov 20 '18 at 15:42
This answer was added before the question was updated. I'll add a comment on the answer to explain as you're right that, as the question now stands, the answer is no longer correct.
– Yoni Gibbs
Nov 20 '18 at 15:44
ah, ok... got it... thanks for the clarification..
– Roland
Nov 20 '18 at 15:47
add a comment |
UPDATE: the answer below was written before the question was updated and changed how the map was created (see the history of the question for details). As the question now stands, the answer below will no longer work. It does work for the question as originally asked though, I believe.
@Roland is right that your map will never result in that list because there can only ever be a single value in the map against any given key. So I think you need to replace that map with a list of pairs. You can then group it and flatmap it to get your desired result:
val pairs = listOf("a" to 1, "a" to 2, "b" to 3, "b" to 4)
val result = pairs
.groupBy { it.first }
.flatMap { (key, values) -> listOf(key).plus(values.map { it.second }) }
Another slightly different option which you might decide is more readable is this:
val result = pairs
.groupBy({ it.first }, { it.second })
.flatMap { (key, values) -> listOf(key).plus(values) }
cool thanks, this one suits better to my original question.
– svkaka
Nov 20 '18 at 15:25
why do you group it first? we already have a map?
– Roland
Nov 20 '18 at 15:42
This answer was added before the question was updated. I'll add a comment on the answer to explain as you're right that, as the question now stands, the answer is no longer correct.
– Yoni Gibbs
Nov 20 '18 at 15:44
ah, ok... got it... thanks for the clarification..
– Roland
Nov 20 '18 at 15:47
add a comment |
UPDATE: the answer below was written before the question was updated and changed how the map was created (see the history of the question for details). As the question now stands, the answer below will no longer work. It does work for the question as originally asked though, I believe.
@Roland is right that your map will never result in that list because there can only ever be a single value in the map against any given key. So I think you need to replace that map with a list of pairs. You can then group it and flatmap it to get your desired result:
val pairs = listOf("a" to 1, "a" to 2, "b" to 3, "b" to 4)
val result = pairs
.groupBy { it.first }
.flatMap { (key, values) -> listOf(key).plus(values.map { it.second }) }
Another slightly different option which you might decide is more readable is this:
val result = pairs
.groupBy({ it.first }, { it.second })
.flatMap { (key, values) -> listOf(key).plus(values) }
UPDATE: the answer below was written before the question was updated and changed how the map was created (see the history of the question for details). As the question now stands, the answer below will no longer work. It does work for the question as originally asked though, I believe.
@Roland is right that your map will never result in that list because there can only ever be a single value in the map against any given key. So I think you need to replace that map with a list of pairs. You can then group it and flatmap it to get your desired result:
val pairs = listOf("a" to 1, "a" to 2, "b" to 3, "b" to 4)
val result = pairs
.groupBy { it.first }
.flatMap { (key, values) -> listOf(key).plus(values.map { it.second }) }
Another slightly different option which you might decide is more readable is this:
val result = pairs
.groupBy({ it.first }, { it.second })
.flatMap { (key, values) -> listOf(key).plus(values) }
edited Nov 20 '18 at 15:45
answered Nov 20 '18 at 13:45
Yoni GibbsYoni Gibbs
1,303113
1,303113
cool thanks, this one suits better to my original question.
– svkaka
Nov 20 '18 at 15:25
why do you group it first? we already have a map?
– Roland
Nov 20 '18 at 15:42
This answer was added before the question was updated. I'll add a comment on the answer to explain as you're right that, as the question now stands, the answer is no longer correct.
– Yoni Gibbs
Nov 20 '18 at 15:44
ah, ok... got it... thanks for the clarification..
– Roland
Nov 20 '18 at 15:47
add a comment |
cool thanks, this one suits better to my original question.
– svkaka
Nov 20 '18 at 15:25
why do you group it first? we already have a map?
– Roland
Nov 20 '18 at 15:42
This answer was added before the question was updated. I'll add a comment on the answer to explain as you're right that, as the question now stands, the answer is no longer correct.
– Yoni Gibbs
Nov 20 '18 at 15:44
ah, ok... got it... thanks for the clarification..
– Roland
Nov 20 '18 at 15:47
cool thanks, this one suits better to my original question.
– svkaka
Nov 20 '18 at 15:25
cool thanks, this one suits better to my original question.
– svkaka
Nov 20 '18 at 15:25
why do you group it first? we already have a map?
– Roland
Nov 20 '18 at 15:42
why do you group it first? we already have a map?
– Roland
Nov 20 '18 at 15:42
This answer was added before the question was updated. I'll add a comment on the answer to explain as you're right that, as the question now stands, the answer is no longer correct.
– Yoni Gibbs
Nov 20 '18 at 15:44
This answer was added before the question was updated. I'll add a comment on the answer to explain as you're right that, as the question now stands, the answer is no longer correct.
– Yoni Gibbs
Nov 20 '18 at 15:44
ah, ok... got it... thanks for the clarification..
– Roland
Nov 20 '18 at 15:47
ah, ok... got it... thanks for the clarification..
– Roland
Nov 20 '18 at 15:47
add a comment |
You can flatMap
over map.entries
. Have a look at this function:
val map = mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
println(map)
val flattened : List<Any> = map.entries.flatMap {entry ->
//create list with key as only element, must be type <Any> to add other stuff later
val list = mutableListOf<Any>(entry.key)
//add values
list.addAll(entry.value)
list
}
println(flattened)
prints:
{a=[1, 2], b=[3, 4]}
[a, 1, 2, b, 3, 4]
@Rolands answer inspired this even simpler, more idiomatic version. It essentially does the same, but crams everything into one line:
val flattened: List<Any> = map.flatMap {entry ->
listOf(entry.key) + entry.value
}
thanks, this one is quite harder to read but works well
– svkaka
Nov 20 '18 at 15:36
1
Once you get used to functional programming it will be immediately clear what it does. I dont think it gets any simpler, if you want to preserve the order of the keys and values. In the link you also find a different version withfold
maybe you like that one better ;)
– leonardkraemer
Nov 20 '18 at 15:38
also thanks for the link to function :)
– svkaka
Nov 20 '18 at 15:42
Look at the update, maybe you'll find it easier.
– leonardkraemer
Nov 20 '18 at 15:47
add a comment |
You can flatMap
over map.entries
. Have a look at this function:
val map = mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
println(map)
val flattened : List<Any> = map.entries.flatMap {entry ->
//create list with key as only element, must be type <Any> to add other stuff later
val list = mutableListOf<Any>(entry.key)
//add values
list.addAll(entry.value)
list
}
println(flattened)
prints:
{a=[1, 2], b=[3, 4]}
[a, 1, 2, b, 3, 4]
@Rolands answer inspired this even simpler, more idiomatic version. It essentially does the same, but crams everything into one line:
val flattened: List<Any> = map.flatMap {entry ->
listOf(entry.key) + entry.value
}
thanks, this one is quite harder to read but works well
– svkaka
Nov 20 '18 at 15:36
1
Once you get used to functional programming it will be immediately clear what it does. I dont think it gets any simpler, if you want to preserve the order of the keys and values. In the link you also find a different version withfold
maybe you like that one better ;)
– leonardkraemer
Nov 20 '18 at 15:38
also thanks for the link to function :)
– svkaka
Nov 20 '18 at 15:42
Look at the update, maybe you'll find it easier.
– leonardkraemer
Nov 20 '18 at 15:47
add a comment |
You can flatMap
over map.entries
. Have a look at this function:
val map = mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
println(map)
val flattened : List<Any> = map.entries.flatMap {entry ->
//create list with key as only element, must be type <Any> to add other stuff later
val list = mutableListOf<Any>(entry.key)
//add values
list.addAll(entry.value)
list
}
println(flattened)
prints:
{a=[1, 2], b=[3, 4]}
[a, 1, 2, b, 3, 4]
@Rolands answer inspired this even simpler, more idiomatic version. It essentially does the same, but crams everything into one line:
val flattened: List<Any> = map.flatMap {entry ->
listOf(entry.key) + entry.value
}
You can flatMap
over map.entries
. Have a look at this function:
val map = mapOf("a" to listOf(1,2),
"b" to listOf(3,4))
println(map)
val flattened : List<Any> = map.entries.flatMap {entry ->
//create list with key as only element, must be type <Any> to add other stuff later
val list = mutableListOf<Any>(entry.key)
//add values
list.addAll(entry.value)
list
}
println(flattened)
prints:
{a=[1, 2], b=[3, 4]}
[a, 1, 2, b, 3, 4]
@Rolands answer inspired this even simpler, more idiomatic version. It essentially does the same, but crams everything into one line:
val flattened: List<Any> = map.flatMap {entry ->
listOf(entry.key) + entry.value
}
edited Nov 20 '18 at 15:52
answered Nov 20 '18 at 15:22
leonardkraemerleonardkraemer
3,45111532
3,45111532
thanks, this one is quite harder to read but works well
– svkaka
Nov 20 '18 at 15:36
1
Once you get used to functional programming it will be immediately clear what it does. I dont think it gets any simpler, if you want to preserve the order of the keys and values. In the link you also find a different version withfold
maybe you like that one better ;)
– leonardkraemer
Nov 20 '18 at 15:38
also thanks for the link to function :)
– svkaka
Nov 20 '18 at 15:42
Look at the update, maybe you'll find it easier.
– leonardkraemer
Nov 20 '18 at 15:47
add a comment |
thanks, this one is quite harder to read but works well
– svkaka
Nov 20 '18 at 15:36
1
Once you get used to functional programming it will be immediately clear what it does. I dont think it gets any simpler, if you want to preserve the order of the keys and values. In the link you also find a different version withfold
maybe you like that one better ;)
– leonardkraemer
Nov 20 '18 at 15:38
also thanks for the link to function :)
– svkaka
Nov 20 '18 at 15:42
Look at the update, maybe you'll find it easier.
– leonardkraemer
Nov 20 '18 at 15:47
thanks, this one is quite harder to read but works well
– svkaka
Nov 20 '18 at 15:36
thanks, this one is quite harder to read but works well
– svkaka
Nov 20 '18 at 15:36
1
1
Once you get used to functional programming it will be immediately clear what it does. I dont think it gets any simpler, if you want to preserve the order of the keys and values. In the link you also find a different version with
fold
maybe you like that one better ;)– leonardkraemer
Nov 20 '18 at 15:38
Once you get used to functional programming it will be immediately clear what it does. I dont think it gets any simpler, if you want to preserve the order of the keys and values. In the link you also find a different version with
fold
maybe you like that one better ;)– leonardkraemer
Nov 20 '18 at 15:38
also thanks for the link to function :)
– svkaka
Nov 20 '18 at 15:42
also thanks for the link to function :)
– svkaka
Nov 20 '18 at 15:42
Look at the update, maybe you'll find it easier.
– leonardkraemer
Nov 20 '18 at 15:47
Look at the update, maybe you'll find it easier.
– leonardkraemer
Nov 20 '18 at 15:47
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393182%2fkotlin-is-there-a-way-to-flatten-mapk-out-t-listv-out-t-to-listt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
there is no way that you ever get such a list out of that map. The reason is, that when you create the map this way you actually get a map containing:
"a"
with2
and"b"
with value4
. Otherwise: yes... you can flatten it... maybe with something like:mapOf(...).flatMap { (string, int) -> listOf(string, int) }
or similar...map.flatMap { (string, ints) -> listOf(string).plus(ints) }
– Roland
Nov 20 '18 at 12:46
@Roland sorry my bad, I updated question. Your
map.flatMap { (string, ints) -> listOf(string).plus(ints) }
works well for me. thanks– svkaka
Nov 20 '18 at 15:15