collect Questions

3

I have two simple class ImageEntity and ImageList how to collect result list ImageEntity to ImageList ? List<File> files = listFiles(); ImageList imageList = files.stream().map(file -> ...
St asked 26/4, 2016 at 5:11

4

Solved

I'm porting a piece of code from .NET to Java and stumbled upon a scenario where I want to use stream to map & reduce. class Content { private String propA, propB, propC; Content(String a, S...
Flogging asked 22/3, 2016 at 18:21

9

I'm new to Scala and trying to figure out the best way to filter & map a collection. Here's a toy example to explain my problem. Approach 1: This is pretty bad since I'm iterating through the ...
Pokeberry asked 15/6, 2015 at 1:8

1

Solved

I have the following code: Stream.of("1,2,3,4".split(",")).mapToDouble(Double::valueOf).collect(Collectors.toList()); I want to return List<Double>. This code doesn't compile. I see erro...
Almeria asked 7/10, 2015 at 14:6

2

Solved

Lets say we have this boring piece of code that we all had to use: ArrayList<Long> ids = new ArrayList<Long>(); for (MyObj obj : myList){ ids.add(obj.getId()); } After switching to ...
Jazminejazz asked 13/11, 2014 at 9:25

2

Solved

I know that I can do a query for recent books based on an array as in scope :recent_books, lambda {|since_dt| {:conditions=>{:created_at >= since_dt}}} but how can I do a similar query when...
Ingather asked 16/11, 2011 at 16:32

7

Solved

From this code I don't know the difference between the two methods, collect and each. a = ["L","Z","J"].collect{|x| puts x.succ} #=> M AA K print a.class #=> Array b = ["L","Z","J"]....
Excommunicative asked 18/3, 2011 at 4:6

1

Solved

I have a collection and I'm wanting to find certain elements and transform them. I can do this in two closures but I was wondering if it is possible with only one? def c = [1, 2, 3, 4] def result...
Asseveration asked 7/1, 2014 at 13:37

3

Solved

I'm going through log file that is too big to fit into memory and collecting 2 type of expressions, what is better functional alternative to my iterative snippet below? def streamData(file: File,...
Evelineevelinn asked 5/2, 2013 at 5:10

1

Solved

i would like to get all images/photos/wallpapers from my android device with image saved path. I have implemented code for collect the images from sdcard as follows: String[] mProjection = { Med...
Dicrotic asked 14/7, 2012 at 7:9

2

I am using Rails 3.2.2 and I would like to quote all array elements with ' and return a string containing all those quoted and comma-separated elements. At this time I am using ['a', 'b', 'c'].col...
Pigpen asked 18/5, 2012 at 5:47

4

Solved

So I have an array built by collect. @a = Relation.where(part: "v04") @relations = @a.collect {|x| x.car} Builds.. => ["f03", "f04"] @a = Relation.where(part: "v03") @relations = @a.colle...
Exsert asked 1/9, 2012 at 19:16

3

Solved

I have a class like this: class Foo { static hasMany = [bars: Bar] } When I write: Foo.getAll() I get a list of Foo objects like this: [ Foo1, Foo2, Foo3 ] When I write: Foo.getAll().bar...
Inspissate asked 20/6, 2012 at 23:56

4

Solved

Possible Duplicate: How do I get the nth element from a Dictionary? If there's a Dictionary with total of Y items and we need Nth item when N < Y then how to achieve this? Example...
Baldhead asked 17/6, 2011 at 10:37

4

Solved

I have an application I am making that creates a large number of windows controls (buttons and labels etc). They are all being made dynamically through functions. The problem I'm having is, when I ...
Alkali asked 12/1, 2010 at 6:3

2

Solved

What is the Linq equivalent to the map! or collect! method in Ruby? a = [ "a", "b", "c", "d" ] a.collect! {|x| x + "!" } a #=> [ "a!", "b!", "c!", "d!" ] I could do this by iterating over ...
Icing asked 31/3, 2009 at 17:23

© 2022 - 2024 — McMap. All rights reserved.