please suggest best way to write an anonymous function here









up vote
-1
down vote

favorite












Please suggest best way to write an inline function at the place where func_1 is being called. Also it should do something what func_1 is trying to do
(I am aware that a function cannot return two things in scala)



I am reading lines from a file(args(0)), where each line consists of numbers separated by comma.
For each line first number nodeId and other numbers are its neighbours
For first 5 lines first number itself is cluseterId.
graph contains each node with Long:nodeId,Long:clusterId and List[Long]:neighbours



I am trying to write a map reduce kind of functionality where this function "func_1" is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally



import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
import scala.collection.mutable.ListBuffer

object Partition

val depth = 6

def func_1(nodeId:Long,clusterId:Long,neightbours:List[Long]):Either[(Long,Long,List[Long]),(Long,Long)]=
Left(nodeId,clusterId,neightbours)
for(x <- neightbours)
if(clusterId > -1)
Right(x,clusterId)



def func_2()


def main ( args: Array[ String ] )
val conf=new SparkConf().setAppName("Partition")
val sc=new SparkContext(conf)
var count : Int = 0

var graph=sc.textFile(args(0)).map(line =>
var nodeId:Long=line(0).toLong
var clusterId:Long=1
var neighbours=new ListBuffer[Long]()
if(count < 5)
clusterId=line(0).toLong
else
clusterId= -1 * clusterId

val nums=line.split(",")
for(i <- 1 to line.length()-1)
neighbours.+=(nums(i).toLong)

(nodeId,clusterId,neighbours.toList)
).collect()
graph.foreach(println)
for (i <- 1 to depth)
graph = graph.flatMap func_1 .groupByKey.map /* (2) */
/* finally, print partition sizes */












share|improve this question























  • What are you trying to do? Is this "if clusterId is > -1, then return just the clusterId, otherwise return the clusterId and the neighbours". You have to return "either" something of (Long,List[Long]) or something of the type Long. Sounds like you want something more like def func_1.... = if(clusterId > -1) Right(clusterId) else Left(clusterId, neightbours)
    – Sidd Singal
    Nov 8 at 20:13











  • @siddSingal: let me modify my question
    – nikhil kekan
    Nov 8 at 20:19










  • @siddsingal: now i am trying to return tuple of either (Long,Long,List[Long]) or (Long,Long) still gettting the same error
    – nikhil kekan
    Nov 8 at 20:21










  • Why do you need the for loop? The clusterId isn't going to change for each neighbor
    – Sidd Singal
    Nov 8 at 20:24






  • 1




    Also, the reason you are getting an error is because a scala "for" loop isn't an expression. It doesn't return anything. That entire statement will evaluate to nothing (or Unit). You can assign the output to a variable and then add the variable at the end to return t.
    – Sidd Singal
    Nov 8 at 20:26














up vote
-1
down vote

favorite












Please suggest best way to write an inline function at the place where func_1 is being called. Also it should do something what func_1 is trying to do
(I am aware that a function cannot return two things in scala)



I am reading lines from a file(args(0)), where each line consists of numbers separated by comma.
For each line first number nodeId and other numbers are its neighbours
For first 5 lines first number itself is cluseterId.
graph contains each node with Long:nodeId,Long:clusterId and List[Long]:neighbours



I am trying to write a map reduce kind of functionality where this function "func_1" is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally



import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
import scala.collection.mutable.ListBuffer

object Partition

val depth = 6

def func_1(nodeId:Long,clusterId:Long,neightbours:List[Long]):Either[(Long,Long,List[Long]),(Long,Long)]=
Left(nodeId,clusterId,neightbours)
for(x <- neightbours)
if(clusterId > -1)
Right(x,clusterId)



def func_2()


def main ( args: Array[ String ] )
val conf=new SparkConf().setAppName("Partition")
val sc=new SparkContext(conf)
var count : Int = 0

var graph=sc.textFile(args(0)).map(line =>
var nodeId:Long=line(0).toLong
var clusterId:Long=1
var neighbours=new ListBuffer[Long]()
if(count < 5)
clusterId=line(0).toLong
else
clusterId= -1 * clusterId

val nums=line.split(",")
for(i <- 1 to line.length()-1)
neighbours.+=(nums(i).toLong)

(nodeId,clusterId,neighbours.toList)
).collect()
graph.foreach(println)
for (i <- 1 to depth)
graph = graph.flatMap func_1 .groupByKey.map /* (2) */
/* finally, print partition sizes */












share|improve this question























  • What are you trying to do? Is this "if clusterId is > -1, then return just the clusterId, otherwise return the clusterId and the neighbours". You have to return "either" something of (Long,List[Long]) or something of the type Long. Sounds like you want something more like def func_1.... = if(clusterId > -1) Right(clusterId) else Left(clusterId, neightbours)
    – Sidd Singal
    Nov 8 at 20:13











  • @siddSingal: let me modify my question
    – nikhil kekan
    Nov 8 at 20:19










  • @siddsingal: now i am trying to return tuple of either (Long,Long,List[Long]) or (Long,Long) still gettting the same error
    – nikhil kekan
    Nov 8 at 20:21










  • Why do you need the for loop? The clusterId isn't going to change for each neighbor
    – Sidd Singal
    Nov 8 at 20:24






  • 1




    Also, the reason you are getting an error is because a scala "for" loop isn't an expression. It doesn't return anything. That entire statement will evaluate to nothing (or Unit). You can assign the output to a variable and then add the variable at the end to return t.
    – Sidd Singal
    Nov 8 at 20:26












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











Please suggest best way to write an inline function at the place where func_1 is being called. Also it should do something what func_1 is trying to do
(I am aware that a function cannot return two things in scala)



I am reading lines from a file(args(0)), where each line consists of numbers separated by comma.
For each line first number nodeId and other numbers are its neighbours
For first 5 lines first number itself is cluseterId.
graph contains each node with Long:nodeId,Long:clusterId and List[Long]:neighbours



I am trying to write a map reduce kind of functionality where this function "func_1" is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally



import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
import scala.collection.mutable.ListBuffer

object Partition

val depth = 6

def func_1(nodeId:Long,clusterId:Long,neightbours:List[Long]):Either[(Long,Long,List[Long]),(Long,Long)]=
Left(nodeId,clusterId,neightbours)
for(x <- neightbours)
if(clusterId > -1)
Right(x,clusterId)



def func_2()


def main ( args: Array[ String ] )
val conf=new SparkConf().setAppName("Partition")
val sc=new SparkContext(conf)
var count : Int = 0

var graph=sc.textFile(args(0)).map(line =>
var nodeId:Long=line(0).toLong
var clusterId:Long=1
var neighbours=new ListBuffer[Long]()
if(count < 5)
clusterId=line(0).toLong
else
clusterId= -1 * clusterId

val nums=line.split(",")
for(i <- 1 to line.length()-1)
neighbours.+=(nums(i).toLong)

(nodeId,clusterId,neighbours.toList)
).collect()
graph.foreach(println)
for (i <- 1 to depth)
graph = graph.flatMap func_1 .groupByKey.map /* (2) */
/* finally, print partition sizes */












share|improve this question















Please suggest best way to write an inline function at the place where func_1 is being called. Also it should do something what func_1 is trying to do
(I am aware that a function cannot return two things in scala)



I am reading lines from a file(args(0)), where each line consists of numbers separated by comma.
For each line first number nodeId and other numbers are its neighbours
For first 5 lines first number itself is cluseterId.
graph contains each node with Long:nodeId,Long:clusterId and List[Long]:neighbours



I am trying to write a map reduce kind of functionality where this function "func_1" is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally



import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
import scala.collection.mutable.ListBuffer

object Partition

val depth = 6

def func_1(nodeId:Long,clusterId:Long,neightbours:List[Long]):Either[(Long,Long,List[Long]),(Long,Long)]=
Left(nodeId,clusterId,neightbours)
for(x <- neightbours)
if(clusterId > -1)
Right(x,clusterId)



def func_2()


def main ( args: Array[ String ] )
val conf=new SparkConf().setAppName("Partition")
val sc=new SparkContext(conf)
var count : Int = 0

var graph=sc.textFile(args(0)).map(line =>
var nodeId:Long=line(0).toLong
var clusterId:Long=1
var neighbours=new ListBuffer[Long]()
if(count < 5)
clusterId=line(0).toLong
else
clusterId= -1 * clusterId

val nums=line.split(",")
for(i <- 1 to line.length()-1)
neighbours.+=(nums(i).toLong)

(nodeId,clusterId,neighbours.toList)
).collect()
graph.foreach(println)
for (i <- 1 to depth)
graph = graph.flatMap func_1 .groupByKey.map /* (2) */
/* finally, print partition sizes */









scala apache-spark functional-programming mapreduce either






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 21:49

























asked Nov 8 at 20:08









nikhil kekan

208




208











  • What are you trying to do? Is this "if clusterId is > -1, then return just the clusterId, otherwise return the clusterId and the neighbours". You have to return "either" something of (Long,List[Long]) or something of the type Long. Sounds like you want something more like def func_1.... = if(clusterId > -1) Right(clusterId) else Left(clusterId, neightbours)
    – Sidd Singal
    Nov 8 at 20:13











  • @siddSingal: let me modify my question
    – nikhil kekan
    Nov 8 at 20:19










  • @siddsingal: now i am trying to return tuple of either (Long,Long,List[Long]) or (Long,Long) still gettting the same error
    – nikhil kekan
    Nov 8 at 20:21










  • Why do you need the for loop? The clusterId isn't going to change for each neighbor
    – Sidd Singal
    Nov 8 at 20:24






  • 1




    Also, the reason you are getting an error is because a scala "for" loop isn't an expression. It doesn't return anything. That entire statement will evaluate to nothing (or Unit). You can assign the output to a variable and then add the variable at the end to return t.
    – Sidd Singal
    Nov 8 at 20:26
















  • What are you trying to do? Is this "if clusterId is > -1, then return just the clusterId, otherwise return the clusterId and the neighbours". You have to return "either" something of (Long,List[Long]) or something of the type Long. Sounds like you want something more like def func_1.... = if(clusterId > -1) Right(clusterId) else Left(clusterId, neightbours)
    – Sidd Singal
    Nov 8 at 20:13











  • @siddSingal: let me modify my question
    – nikhil kekan
    Nov 8 at 20:19










  • @siddsingal: now i am trying to return tuple of either (Long,Long,List[Long]) or (Long,Long) still gettting the same error
    – nikhil kekan
    Nov 8 at 20:21










  • Why do you need the for loop? The clusterId isn't going to change for each neighbor
    – Sidd Singal
    Nov 8 at 20:24






  • 1




    Also, the reason you are getting an error is because a scala "for" loop isn't an expression. It doesn't return anything. That entire statement will evaluate to nothing (or Unit). You can assign the output to a variable and then add the variable at the end to return t.
    – Sidd Singal
    Nov 8 at 20:26















What are you trying to do? Is this "if clusterId is > -1, then return just the clusterId, otherwise return the clusterId and the neighbours". You have to return "either" something of (Long,List[Long]) or something of the type Long. Sounds like you want something more like def func_1.... = if(clusterId > -1) Right(clusterId) else Left(clusterId, neightbours)
– Sidd Singal
Nov 8 at 20:13





What are you trying to do? Is this "if clusterId is > -1, then return just the clusterId, otherwise return the clusterId and the neighbours". You have to return "either" something of (Long,List[Long]) or something of the type Long. Sounds like you want something more like def func_1.... = if(clusterId > -1) Right(clusterId) else Left(clusterId, neightbours)
– Sidd Singal
Nov 8 at 20:13













@siddSingal: let me modify my question
– nikhil kekan
Nov 8 at 20:19




@siddSingal: let me modify my question
– nikhil kekan
Nov 8 at 20:19












@siddsingal: now i am trying to return tuple of either (Long,Long,List[Long]) or (Long,Long) still gettting the same error
– nikhil kekan
Nov 8 at 20:21




@siddsingal: now i am trying to return tuple of either (Long,Long,List[Long]) or (Long,Long) still gettting the same error
– nikhil kekan
Nov 8 at 20:21












Why do you need the for loop? The clusterId isn't going to change for each neighbor
– Sidd Singal
Nov 8 at 20:24




Why do you need the for loop? The clusterId isn't going to change for each neighbor
– Sidd Singal
Nov 8 at 20:24




1




1




Also, the reason you are getting an error is because a scala "for" loop isn't an expression. It doesn't return anything. That entire statement will evaluate to nothing (or Unit). You can assign the output to a variable and then add the variable at the end to return t.
– Sidd Singal
Nov 8 at 20:26




Also, the reason you are getting an error is because a scala "for" loop isn't an expression. It doesn't return anything. That entire statement will evaluate to nothing (or Unit). You can assign the output to a variable and then add the variable at the end to return t.
– Sidd Singal
Nov 8 at 20:26












1 Answer
1






active

oldest

votes

















up vote
1
down vote













It's really hard to figure out what you want because your code makes absolutely no sense.



I'm going to take a wild guess that you might be looking for something like this.



def func_1(nodeId :Long
,clusterId :Long
,neightbours :List[Long]
) :Either[(Long,Long,List[Long]),List[(Long,Long)]] =

if (clusterId > -1) Right(neightbours.map(_ -> clusterId))
else Left(nodeId, clusterId, neightbours)


At least this compiles, and that's a place to start.




def func_1( ... ) :Either[ ... ] = //a method that returns an Either

Left(nodeId,clusterId,neightbours) //create a Left expression of the Either
//don't do anything with it, throw it away
for(x <- neightbours) //grab all the neightbours (spelling?)
if(clusterId > -1) //if clusterId is positive
Right(x,clusterId) //create a Right expression of the Either
//don't do anything with it, throw it away

//I'm done, return nothing





share|improve this answer






















  • I am trying to write a map reduce kind of functionality where this function is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally
    – nikhil kekan
    Nov 8 at 20:35










  • Not only does your code make no sense, your explanation makes no sense. Type Either is of type Right or type Left. It can't be both. And a method can't "emit" something and then do something more. To emit means to return. When a routine returns something then it is finished and doesn't exist anymore.
    – jwvh
    Nov 8 at 20:43










  • I am sorry for not describing my problem in context of scala. updating my question again
    – nikhil kekan
    Nov 8 at 20:47










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',
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
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53215387%2fplease-suggest-best-way-to-write-an-anonymous-function-here%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













It's really hard to figure out what you want because your code makes absolutely no sense.



I'm going to take a wild guess that you might be looking for something like this.



def func_1(nodeId :Long
,clusterId :Long
,neightbours :List[Long]
) :Either[(Long,Long,List[Long]),List[(Long,Long)]] =

if (clusterId > -1) Right(neightbours.map(_ -> clusterId))
else Left(nodeId, clusterId, neightbours)


At least this compiles, and that's a place to start.




def func_1( ... ) :Either[ ... ] = //a method that returns an Either

Left(nodeId,clusterId,neightbours) //create a Left expression of the Either
//don't do anything with it, throw it away
for(x <- neightbours) //grab all the neightbours (spelling?)
if(clusterId > -1) //if clusterId is positive
Right(x,clusterId) //create a Right expression of the Either
//don't do anything with it, throw it away

//I'm done, return nothing





share|improve this answer






















  • I am trying to write a map reduce kind of functionality where this function is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally
    – nikhil kekan
    Nov 8 at 20:35










  • Not only does your code make no sense, your explanation makes no sense. Type Either is of type Right or type Left. It can't be both. And a method can't "emit" something and then do something more. To emit means to return. When a routine returns something then it is finished and doesn't exist anymore.
    – jwvh
    Nov 8 at 20:43










  • I am sorry for not describing my problem in context of scala. updating my question again
    – nikhil kekan
    Nov 8 at 20:47














up vote
1
down vote













It's really hard to figure out what you want because your code makes absolutely no sense.



I'm going to take a wild guess that you might be looking for something like this.



def func_1(nodeId :Long
,clusterId :Long
,neightbours :List[Long]
) :Either[(Long,Long,List[Long]),List[(Long,Long)]] =

if (clusterId > -1) Right(neightbours.map(_ -> clusterId))
else Left(nodeId, clusterId, neightbours)


At least this compiles, and that's a place to start.




def func_1( ... ) :Either[ ... ] = //a method that returns an Either

Left(nodeId,clusterId,neightbours) //create a Left expression of the Either
//don't do anything with it, throw it away
for(x <- neightbours) //grab all the neightbours (spelling?)
if(clusterId > -1) //if clusterId is positive
Right(x,clusterId) //create a Right expression of the Either
//don't do anything with it, throw it away

//I'm done, return nothing





share|improve this answer






















  • I am trying to write a map reduce kind of functionality where this function is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally
    – nikhil kekan
    Nov 8 at 20:35










  • Not only does your code make no sense, your explanation makes no sense. Type Either is of type Right or type Left. It can't be both. And a method can't "emit" something and then do something more. To emit means to return. When a routine returns something then it is finished and doesn't exist anymore.
    – jwvh
    Nov 8 at 20:43










  • I am sorry for not describing my problem in context of scala. updating my question again
    – nikhil kekan
    Nov 8 at 20:47












up vote
1
down vote










up vote
1
down vote









It's really hard to figure out what you want because your code makes absolutely no sense.



I'm going to take a wild guess that you might be looking for something like this.



def func_1(nodeId :Long
,clusterId :Long
,neightbours :List[Long]
) :Either[(Long,Long,List[Long]),List[(Long,Long)]] =

if (clusterId > -1) Right(neightbours.map(_ -> clusterId))
else Left(nodeId, clusterId, neightbours)


At least this compiles, and that's a place to start.




def func_1( ... ) :Either[ ... ] = //a method that returns an Either

Left(nodeId,clusterId,neightbours) //create a Left expression of the Either
//don't do anything with it, throw it away
for(x <- neightbours) //grab all the neightbours (spelling?)
if(clusterId > -1) //if clusterId is positive
Right(x,clusterId) //create a Right expression of the Either
//don't do anything with it, throw it away

//I'm done, return nothing





share|improve this answer














It's really hard to figure out what you want because your code makes absolutely no sense.



I'm going to take a wild guess that you might be looking for something like this.



def func_1(nodeId :Long
,clusterId :Long
,neightbours :List[Long]
) :Either[(Long,Long,List[Long]),List[(Long,Long)]] =

if (clusterId > -1) Right(neightbours.map(_ -> clusterId))
else Left(nodeId, clusterId, neightbours)


At least this compiles, and that's a place to start.




def func_1( ... ) :Either[ ... ] = //a method that returns an Either

Left(nodeId,clusterId,neightbours) //create a Left expression of the Either
//don't do anything with it, throw it away
for(x <- neightbours) //grab all the neightbours (spelling?)
if(clusterId > -1) //if clusterId is positive
Right(x,clusterId) //create a Right expression of the Either
//don't do anything with it, throw it away

//I'm done, return nothing






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 8 at 22:06









Brad Larson

161k40363541




161k40363541










answered Nov 8 at 20:30









jwvh

24.6k52038




24.6k52038











  • I am trying to write a map reduce kind of functionality where this function is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally
    – nikhil kekan
    Nov 8 at 20:35










  • Not only does your code make no sense, your explanation makes no sense. Type Either is of type Right or type Left. It can't be both. And a method can't "emit" something and then do something more. To emit means to return. When a routine returns something then it is finished and doesn't exist anymore.
    – jwvh
    Nov 8 at 20:43










  • I am sorry for not describing my problem in context of scala. updating my question again
    – nikhil kekan
    Nov 8 at 20:47
















  • I am trying to write a map reduce kind of functionality where this function is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally
    – nikhil kekan
    Nov 8 at 20:35










  • Not only does your code make no sense, your explanation makes no sense. Type Either is of type Right or type Left. It can't be both. And a method can't "emit" something and then do something more. To emit means to return. When a routine returns something then it is finished and doesn't exist anymore.
    – jwvh
    Nov 8 at 20:43










  • I am sorry for not describing my problem in context of scala. updating my question again
    – nikhil kekan
    Nov 8 at 20:47















I am trying to write a map reduce kind of functionality where this function is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally
– nikhil kekan
Nov 8 at 20:35




I am trying to write a map reduce kind of functionality where this function is like a mapper which emits (nodeId,clusterId,neighbours) and then checks for every element in neighbours and if clusterId > -1 then emits (nodeId,clusterId). In short tuple (nodeId,clusterId,neighbours) has to be emitted unconditionally
– nikhil kekan
Nov 8 at 20:35












Not only does your code make no sense, your explanation makes no sense. Type Either is of type Right or type Left. It can't be both. And a method can't "emit" something and then do something more. To emit means to return. When a routine returns something then it is finished and doesn't exist anymore.
– jwvh
Nov 8 at 20:43




Not only does your code make no sense, your explanation makes no sense. Type Either is of type Right or type Left. It can't be both. And a method can't "emit" something and then do something more. To emit means to return. When a routine returns something then it is finished and doesn't exist anymore.
– jwvh
Nov 8 at 20:43












I am sorry for not describing my problem in context of scala. updating my question again
– nikhil kekan
Nov 8 at 20:47




I am sorry for not describing my problem in context of scala. updating my question again
– nikhil kekan
Nov 8 at 20:47

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53215387%2fplease-suggest-best-way-to-write-an-anonymous-function-here%23new-answer', 'question_page');

);

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







Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)