Basic functional style question

Paul Sandoz paul.sandoz at
Wed Nov 27 03:31:21 PST 2013

On Nov 27, 2013, at 11:47 AM, mohan.radhakrishnan at wrote:

> Yes. Thanks Stuart. 
> I also have these questions.
> 1. How do I apply a large number of regex patterns one by one in the same 
> pipeline ? When is a new functional interface needed ?

Do you want to fork the stream of lines into N separate stream of lines each mapping/filtering using a separate regex?

> 2.  function(){
>        return (data$V1[ grep ("(.*)Full GC(.*)", data[,1])])
>     }
>     Is there a way to do this ? This R code uses code to change values in 
> a data structure in-place. Code and data are together here.

Structural modifications to the source should not be made during executing of the pipeline, otherwise it will lead to either a ConcurrentModificationException or undefined results. 

In place modifications, like the above, might be possible depending on the source, such as an array, but you really need to be careful and know what you are doing e.g. using a forEach with side-effects such that those side-effects are safe under concurrent operation. 

Trying to do this in anything other than forEach is asking for trouble and going against the rules that function values passed to operations should be stateless and not have side-effects (or more specifically side-effects that may effect results, but in general it is best to try and always avoid side-effects).


More information about the lambda-dev mailing list