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.

learn more… | top users | synonyms

3
votes
0answers
15 views

Implementing a generic and covariant Set in Scala

I'm struggling with manually implementing a simple purely functional Set that's also generic and covariant on its type parameter: ...
4
votes
0answers
43 views

Functionally Typed I/O Streams

I thought up a function that provides types with InputStream and OutputStream: ...
2
votes
1answer
24 views

Aggregating values of a path-dependent type

I have a type representing an immutable order which contains immutable order lines that belong to it. I want to use path-dependent types for this. Obviously you cannot instantiate a path-dependent ...
6
votes
1answer
60 views

Sending SMS through twilio from play framework

I am trying to send SMS using Twilio with Scala 2.10 in Playframework 2.2, but this code is looking odd to me, maybe due to lots of conditions. I'm sure it needs some important reviews. ...
0
votes
1answer
32 views

Project Euler problem 31 - tail recursive algorithm [closed]

In Scala, a recursive algorithm for project Euler problem 31 is the following: ...
3
votes
2answers
81 views

Timing Project Euler Problem 1

Is there a better way to time the functions and print the result and function name dynamically? ...
1
vote
4answers
78 views

What can I do about all these Options?

I have the following code, it takes a list of maps representing bands and transforms the band properties via the pipeline_each method. As you can see in the code, I am dealing with a lot of Options ...
2
votes
0answers
66 views

Safely network reconnection (netty based)

I am writing a TCP client app using netty NettyConnectionManager.scala: ...
1
vote
0answers
26 views

Elementary foldMap implementation

I think I got the implementation right, but I'm a bit unsure if this implementation will do fine in terms of space (stack) because I'm doing a foldRight. Would I ...
3
votes
1answer
96 views

Binary search in functional-style Scala

Curious to know how I can improve it, especially the pattern matching part seems a bit repetitive at the moment (lots of case x if ds(x)) ...
3
votes
1answer
48 views

Uploading a video in S3 Using Future

I've posted a similar program previously, but I have not made any major modifications in the code, so I am posting it again by deleting the previous question. I am afraid of the thread keyword and I ...
2
votes
2answers
37 views

Branching with multiple Try

I have a series of four method calls that all return Try[Something], with the last returning Try[Unit]. Something like this: ...
3
votes
2answers
66 views

Update Immutable Map

How's the following function to update an immutable Map's values? ...
5
votes
2answers
50 views

Connecting to RabbitMQ

I would like a review for this connection to RabbitMQ. I just developed it and seems to be working well, but I would like another set of eyes on it before putting this on the sever. ...
0
votes
1answer
57 views

Updating MySQL with shuffled numbers between 1 and 50

I need to assign a number to each userId. I think this is too much of a query for updating. Is it possible to reduce the number of queries, or is it okay? ...
4
votes
4answers
115 views

Random 6 to 10 digits number

I am generating a random numerical 6-10 digit password. I need some important reviews of yours. Is it OK or are there some needed modifications? ...
6
votes
4answers
240 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
0answers
73 views

Scala heap implementation

I'm a Scala beginner, so it'd be great if anyone would be so kind to give some feedback. ...
3
votes
1answer
56 views

Scala Tic Tac Toe Game

This is my first Scala game. I would love some feedback on my coding style, or your brief input on how you would do it. ...
5
votes
2answers
283 views

Parsing JSON to a Map and Set structure

How do I make these line of codes more scala-ish (shorter?). I still get the Java feeling in it (which I want to stay away from). ...
4
votes
1answer
80 views

Finding the longest word from a list of words

I have a list of words (with repetitions), and I intend to find out the longest words amongst them, along with their length. My question is to know if my implementation is too verbose, is using too ...
5
votes
2answers
79 views

Beginner Project: Bunny City

I am a Java programmer, and I just recently started learning Scala for fun. I found a group of projects here, and I tried to do the graduation excercise. The problem is, my code looks a lot like java, ...
4
votes
0answers
83 views

Binary Search Tree Monad Implementation

I've written a Binary Search Tree Monad in Scala. I would like to hear your thoughts on how to improve it (e.g. making insertion/deletion/search faster and more scalable). Also, is there a better way ...
1
vote
0answers
40 views

VerbalExpressions in Scala

I forked the original implementation of VerbalExpressions in Scala here: https://github.com/pathikrit/ScalaVerbalExpressions I am looking forward to these things in the code review: ...
3
votes
2answers
116 views

Apache log4j in play framework

I have converted this code from Java to Scala, and I need reviews. This works fine, but I am sure that something is wrong with this coding pattern. ...
3
votes
0answers
38 views

Custom Scala implementation of generic Future.sequence

I'm trying to make sure I understand how to write clean and robust idiomatic Scala, so I wrote a custom generic implementation sequence of type ...
1
vote
1answer
80 views

Converting object oriented style code to functional in Scala

I came across Java like Scala code that I am trying to refactor to make it functional and immutable. The first obvious flaw is that it's violating thread safety by using mutable public class level ...
2
votes
1answer
56 views

Testing Promises vs Lock performance

I'm not sure if my lock usage is correct and safe. I wanted to know what will be best approach to deal with situation when one thread have to wait for being initialized by another so I written this ...
4
votes
0answers
43 views

Neatly Transforming Anorm ResultSet Into Map[Parent , (Set[Child1], Set[Child2]))]

I have a table Bill containing Bills with 0...n relationships to Material and ...
3
votes
2answers
165 views

Pascal triangle algorithm is good but fails

I have created a function which returns the number that corresponds to the given row and column from the pascal triangle. I have used the formula for this: n! / r! * (r-n)! The code: ...
4
votes
1answer
78 views

Key / Value store with type classes for formatting / parsing

I'm currently working on a Scala HTTP library, fetch, mostly because I have yet to find one that suits all my needs. As part of this library, I need a generic key / value store, which I intend to use ...
1
vote
1answer
41 views

Pattern-matching function

I am new to Scala and I have written a function which uses pattern matching to filter words based on some conditions. It seems to work correctly but I am suspect that I haven't used the Scala pattern ...
3
votes
1answer
55 views

Is there a better way to return values with merge sort?

I have been attempting to learn Scala lately and so have produced a couple of different sorting algorithms to build up my basics. I think I have been lucky with the methods returning exactly what I ...
8
votes
1answer
95 views

Event dispatcher

In the last 2 years or so, I've learned a great deal about how to write better Scala code, but I know that I've barely scratched the surface. This is part of a library that I've been using. It has ...
2
votes
2answers
71 views

What is the best way to conditionally add to an immutable collection in Scala?

I find myself frequently trying to build up Seq's based on some conditionals, but the code I end up with feels verbose and clunky. An example: ...
2
votes
0answers
67 views

Slick database throttling trait based on the Playframework Slick plugin

I implemented a throttled database service trait for wrapping my service code in a future, supplying a slick session and throttling the # of requests in accordance to the length of the thread pool ...
2
votes
1answer
62 views

Find Pythagorean Triple with Perimeter == 24

Learn You a Haskell gives this exercise: Here's a problem that combines tuples and list comprehensions: which right triangle that has integers for all sides and all sides equal to or smaller ...
4
votes
2answers
102 views

Ugly number implementation in scala

I am trying to implement ugly number sequence generation in Scala. Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15... I have ...
1
vote
1answer
74 views

Construct date sequence in Scala

I want to have a continuous date sequence like ['2014-01-01','2014-01-02', ...] Then I define a stream to do that. ...
6
votes
1answer
143 views

Dijkstra-like routing algorithm

I've got the following code to find the shortest path between two nodes using almost-Dijkstra's-algorithm which was written for an exercise, and I'm looking for things to improve my general Scala ...
7
votes
3answers
181 views

How can I make my isSorted function faster?

I made an isSorted function in Scala and Java as well and when I measured the time of functions' run I saw that the Scala version was very slow. It ran about 3.2 ...
1
vote
1answer
64 views

Transform a MongoDb parent reference tree into a deep nested tree

Given a mongodb collection that stores trees as nodes with parent references this methods returns a deep nested tree where every child nodes are stored in a property childs[Seq] ...
1
vote
4answers
82 views

Get lowest integer that is not in set

Is there a better (functional or more idiomatic) way to get the first positive number that is not included in a set? ...
3
votes
2answers
74 views

Range Minimum Query Implementation in Scala

I would like to heat some feedback on this. I'm coming from a Java background and this is my first program in Scala. I solved Range Minimum Query problem. ...
13
votes
4answers
750 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? ...
5
votes
3answers
136 views

Pair matching elements from two lists

Here is a method that takes two lists (l1 and l2) and pairs up elements that "match". As you can see at the end of the code ...
1
vote
1answer
62 views

Implementing Option#map2

Working on an example from Functional Programming in Scala, I'm working on Option#map2: ...
3
votes
1answer
49 views

Writing Traverse Instance for Option

Working on an exercise from Functional Programming in Scala, I implemented a Traverse instance for Option: ...
3
votes
2answers
121 views

Partial octree implementation

I am just now learning Scala a bit on my own time. I wrote some code that works, but was wondering if you could eyeball it to see if its structure can be improved. It is a partial octree ...