Skip to main content

All Questions

Tagged with
0 votes
1 answer
48 views

How to apply pattern match when needed to match a middle element of a Seq() in scala

This is kind of a learning question rather than a programming code, I have a Sequence as below, val inputSeq = Seq("A","B","C","D","E") so I want to ...
Hima_93's user avatar
  • 51
0 votes
0 answers
61 views

List[Future[A]] => Future[(List[A], List[Throwable])] the most correct solution

I have solution: def foo[A](futures: List[Future[A]])(implicit ec: ExecutionContext): Future[(List[A], List[Throwable])] = futures.foldLeft(Future.successful(List.empty[A] -> List.empty[Throwable]...
andrey.ladniy's user avatar
-1 votes
1 answer
68 views

FoldLeft/FoldRight: Scala Compile-Errors

Trying to finish up an assignment and running into the following compiler errors: fp2.scala:144: error: not enough arguments for method foldRight: (xs: List[A], e: B, f: (A, B) => B)B. Unspecified ...
user22677495's user avatar
1 vote
2 answers
150 views

How to access List element present inside a map in scala?

I'm trying to learn scala from last couple of days so please bear with me. I'm bit confused accessing the list element in scala. If it is accessed directly from a list apply method works however if it ...
djm's user avatar
  • 45
0 votes
0 answers
43 views

Passing case class name as a function argument but takes entire path of case class

I have a case class case class S3FileRecords( rank: Integer, name: String, ) and while passing this case class name ...
Sakshi Trivedi's user avatar
1 vote
1 answer
70 views

Store a particular column values of a dataframe in comma separated format in a file in hdfs in scala

I have dataframe which has only one column containing json data strings in it.The size of this dataframe is 50M.I want to store this json strings in comma separated array format in specified numbers ...
Amiya Ghosh's user avatar
1 vote
1 answer
26 views

replacing efficiently an element of a list in the same index with other a sub elements Scala [duplicate]

I want to add other elements to a list in the index of a given item. for instance val list = List(1,2,3,4) I want to replace the element 3 with (3, 7) which will gives this output val list = List(1,2,...
Her sincerly's user avatar
0 votes
1 answer
76 views

Tail Recursion in Scala return List Head each time after dropping it

I have a list of users. Each user might have a field users (like friends). For each user I want to get the users related to that user and return each time the name. Like some recursive function. case ...
Her sincerly's user avatar
0 votes
2 answers
117 views

How to sort a list of custom objects by a specific field in Scala

I'm working on a Scala project where I need to sort a list of custom objects based on a specific field. The objects have a field called score, which is an integer. I want to sort the list of objects ...
devblack.exe's user avatar
1 vote
1 answer
65 views

How to add a element into another list at a certain index without removing or replacing any elements scala

I have a List and Map as below, val exampleList = List("A","B","C","D","E","A","L","M","N") val exampleMap =...
Hima_93's user avatar
  • 51
0 votes
3 answers
104 views

Scala: Sorting a list while keeping the position of placeholders

The problem I'm facing is sorting a List of Double values in Scala also containing some kind of placeholder values (Double.NaN in the example below. However, these can be set as required for the ...
Niklas2501's user avatar
0 votes
0 answers
131 views

How to get input to list from user in Scala?

Counting Change Write a recursive function that counts how many different ways you can make change for an amount, given a list of coin denominations. For example, there are 3 ways to give change for 4 ...
Акерке Орынбасарова's user avatar
2 votes
2 answers
333 views

Could not infer type of parameter

I have created MyList abstract class to implement the list, the reason for not using already present list implementation is I am learning Scala and this was exercise for the same course. I am writing ...
Nikhil Padole's user avatar
0 votes
1 answer
441 views

Scala: add prefix to each element in list

I have a list of some partitions, like: [1, 2, 3, 4] and also I have main path, like: "books/style/type=" I want to get a list of full path, like this: [books/style/type=1/, books/style/...
Pluto's user avatar
  • 37
1 vote
1 answer
76 views

I have a List[(List[A], List[R])] - a List of a tuple of two Lists of objects A and R respectively. How do I "flatten" the List[R] for each List[A]?

I have a List[(List[A], List[R])] - a List of a tuple of two Lists of objects A and R respectively. For example, List[([A1, A2], [R1, R2, R3])] What I want to do is convert this into a List[(List[A], ...
slowhand's user avatar

15 30 50 per page
1
2 3 4 5
83