flatmap Questions
6
Solved
I have a list of objects of class AA that contain a date and a list of objects of class BB:
data class AA(
val date: LocalDate,
val bb: List<BB>
)
@Parcelize
data class BB(
val x: Int,
...
Flapjack asked 5/8, 2019 at 10:38
2
I want to understand why using .flatMap() with async does not return a flatten array.
For example, for Typescript, this returns an array of numbers:
I know Promisse.all and async are useless with a...
Riptide asked 30/12, 2022 at 7:47
4
Solved
I have a list of objects, some of them can be collections. I would like to get a stream of plain objects.
List<Object> objects = List.of(1, 2, "SomeString", List.of(3, 4, 5, 6),
7, List.of...
Oriana asked 3/2, 2019 at 15:45
9
Solved
I am chaining async operations using RxJava, and I'd like to pass some variable downstream:
Observable
.from(modifications)
.flatmap( (data1) -> { return op1(data1); })
...
.flatmap( (data2...
Coburn asked 27/1, 2015 at 17:12
3
Solved
in https://try.kotlinlang.org/#/Kotlin%20Koans/Collections/FlatMap/Task.kt
it has sample of using flatMap and map
seems both are doing the same thing, is there a sample to show the difference of ...
Delphine asked 29/8, 2018 at 13:6
4
Solved
Both map and flatMap are defind on ImplicitlyUnwrappedOptional, but they differ (obviously) in their definition according to the documentation:
func map(f: @noescape (T) -> U) -> U!
If self ...
Graphy asked 10/4, 2015 at 8:23
5
Solved
I'm looking to flatten an array that look like this:
[{
"id": 0,
"text": "item 0"
}, {
"id": 1,
"items": [{
"id": 2,
"text": "item 2"
}, {
"id": 3,
"items": [{
"id": 4,
"text": "item 4"...
Metropolis asked 2/9, 2016 at 17:37
7
Solved
It seems that these 2 functions are pretty similar. They have same signature (accepting rx.functions.Func1<? super T, ? extends Observable<? extends R>> func), and their marble diagrams...
11
Solved
When do you use map vs flatMap in RxJava?
Say, for example, we want to map Files containing JSON into Strings that contain the JSON--
Using map, we have to deal with the Exception somehow. But ho...
5
Solved
I'm a Java beginner, I just got learn about map and flatMap.
When 2d List should be converted to 1d List, it was implemented like below.
List<List<Integer>> list_2d = List.of(List.of(1,...
Impassion asked 20/12, 2020 at 10:14
2
Solved
I have been skimming through the news and the source code of the newest LTE Java 17 version and I have encountered with new Stream method called mapMulti. The early-access JavaDoc says it is simila...
Blamed asked 30/9, 2020 at 7:27
3
According to the Mozilla Developer Website:
The flatMap() method first maps each element using a mapping function, then flattens the result into a new array. It is identical to a map followed by a ...
Multifarious asked 5/4, 2019 at 7:53
3
Solved
I have a set of files. The path to the files are saved in a file., say all_files.txt. Using apache spark, I need to do an operation on all the files and club the results.
The steps that I want to...
Waldman asked 7/11, 2016 at 16:57
3
Solved
Consider this code:
public static void main(String[] args) {
Stream.iterate(1, i -> i + 1)
.flatMap(i -> Stream.of(i, i, i))
.peek(System.out::println)
.limit(4)
.forEach(i -> ...
Prospectus asked 15/3, 2019 at 11:9
3
Solved
Consider the following code:
urls.stream()
.flatMap(url -> fetchDataFromInternet(url).stream())
.filter(...)
.findFirst()
.get();
Will fetchDataFromInternet be called for second url...
Swordtail asked 18/9, 2017 at 22:13
3
Solved
I have a list of animals:
let animals = ["bear", "dog", "cat"]
And some ways to transform that list:
typealias Transform = (String) -> [String]
let containsA: Transform = { $0.contains("a")...
Digger asked 27/1, 2019 at 8:30
5
Solved
I have two methods func1 and func2 which return Optional.
Return Optional as it is if the returned Optional from func1 has value, else call func2 and return its Optional.
One way is to use i...
Stertor asked 18/1, 2019 at 9:43
2
Solved
Observable.just(1)
.flatMap(object : Function<Int, Observable<Int>> {
override fun apply(integer: Int): Observable<Int> {
return Observable.just(integer * 10)
}
})
.flatMap...
5
Solved
I'm a little confused around flatMap (added to Swift 1.2)
Say I have an array of some optional type e.g.
let possibles:[Int?] = [nil, 1, 2, 3, nil, nil, 4, 5]
In Swift 1.1 I'd do a filter foll...
Spurt asked 25/4, 2015 at 20:27
1
Solved
I'm working with an API of my own and a i'm hoping to chain a few paginated results using RxJava. I use cursor based pagination. (imagine there are 50 users in this first request):
{
"data":{
"s...
Conlen asked 12/6, 2018 at 23:8
4
Solved
Say I have something like this:
let values = [1,2,3,4];
let newValues = values.map((v) => {
return v *v ;
});
console.log(newValues); //[1,4,9,16]
Pretty straight forward.
Now what i...
Ischium asked 28/10, 2017 at 5:54
1
Solved
I have this pretty basic and straight forward mapping of an object into dictionary. I am using and parsing dictionary on the top level. One of its fields is an array of other dictionaries. To set t...
3
Solved
We have an array of the Person objects and each object has another array of String, which is optional.
We want the consolidated list of car names in our society.
struct Person {
let name: String...
2
Solved
I was examining .lazy for high order functions and have got some interesting compile errors related to flatMap function (and possibly others)
Examples
let array = [1, 2, 3, 4, 5, 6]
array
.fl...
7
Solved
I have been checking the upcoming Java update, namely: Java 8 or JDK 8. Yes, I am impatient, there's a lot of new stuff, but, there is something I don't understand, some simple code:
final Stream&...
Yonit asked 13/3, 2014 at 14:53
1 Next >
© 2022 - 2024 — McMap. All rights reserved.