Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [scala]

Scala is a general purpose programming language principally targeting the Java Virtual Machine. Designed to express common programming patterns in a concise, elegant, and type-safe way, it fuses both imperative and functional programming styles.

Filter by
Sorted by
Tagged with
26
votes
7answers
5k views

First Scala FizzBuzz implementation

Would love some feedback on this. I'm coming from a Java background and kinda feel like I've just done exactly what I would do in Java. Is there a better way? ...
12
votes
3answers
387 views

Kosaraju in Scala

I started coding in Scala some time ago, and also learning some fundamental algorithms in CS. Here's a terribly slow implementation of Kosaraju algorithm to find strongly connected components in a ...
10
votes
1answer
689 views

BFS and DFS tree traversal

I posted some code as part of an answer to another question and I thought it would be a good idea to get that code reviewed also. Any comments are welcomed, but I am mostly annoyed by ...
7
votes
4answers
6k views

Reducing boilerplate when validating parameters and using a tuple for the parameter list of a case class

I had designed a simple case class that looks like this: case class StreetSecondary(designator: String, value: Option[String]) I needed to add validation (to ...
4
votes
2answers
2k views

BFS tree traversal Scala

I would love some feedback on the following code for BFS traversal in a binary tree. Is there a cleaner way to write this? ...
7
votes
4answers
356 views

Multiple SQL queries, one per ID

ids contains 100 ids that are comma delimited. Is it fine or does it need improvement? ...
4
votes
1answer
5k views

Immutable binary search tree using Scala

I have written a sample immutable binary search tree using Scala. However, I am not sure whether or not I was doing it the proper way since I am not an expert at functional programming. Is there a ...
2
votes
4answers
5k views

Calculating a base price with surcharge conditions

The following code has a lot of conditionals. I am trying to write it in a functional programming way. ...
1
vote
2answers
152 views

Print matrix in spiral order in Scala

Problem: Given a square or rectangular matrix, print its element in spiral order. For example, if input matrix is this: ...
7
votes
3answers
161 views

Distinct sums of integers

I need to get the distinct sums of naturals of a natural What I came up with is: ...
5
votes
2answers
291 views

Change code to use functional style

I tried to solve a programming contest problem in Scala, but I have a feeling, that it could be done in a more functional way. I compared it with the solution written in imperative style and it is not ...
3
votes
1answer
422 views

Initialize a Sieve of Eratosthenes in Scala

I am learning Scala while solving some exercises and I am currently solving an exercise where I need to initialize a Sieve of Eratosthenes. I am using the following code: ...
2
votes
2answers
548 views

Convert a String with comma separated latitudes and longitudes to a Seq[Coordinate]

I have a function that receives a String like the following: "-10.0 -10.0,10.0 10.0,0.0 0.0" And needs to translate that into ...
0
votes
1answer
178 views

Clockwise rotate a matrix in Scala

Given a matrix, clockwise rotate elements in it. Examples: ...