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
4
votes
1answer
377 views

Producing a matrix class that supports any size

I'm doing exercise 11.8 from Scala for impatient, asking to write a matrix class: Provide a class Matrix - you can choose whether you want to implement 2 x 2 ...
5
votes
2answers
296 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 ...
11
votes
4answers
916 views

Alternate form of BufferedInputStream

I was having a problem with the TCP/IP socket communications in a web app where the server that the app was talking to would occasionally send bursts of data that would overflow the low level stream ...
5
votes
1answer
758 views

Connect Four In Idiomatic Scala

Learning Scala I'm trying to learn Scala and I'm interested in criticism about how to make my code more idiomatic. I've programmed a simple Connect-four game. Can I get some feedback? https://github....
2
votes
1answer
1k views

Defining transpose on a collection of irregular collections

I was asked to submit my request for code review on https://stackoverflow.com/questions/10672046/defining-transpose-on-a-collection-of-irregular-collections here. This is a follow-up to the post I ...
2
votes
2answers
234 views

Scala: Josephus problem with Actors

Another stab at the Josephus problem, this time using Actors. N people stand in a circle and every stepth person is eliminated ...
1
vote
1answer
45 views

Which name should I choose for private abstract functionality with a public proxy?

I have an abstract class implementing some concrete functionality for its child classes: ...
3
votes
2answers
162 views

Attempting to eliminate var (and imperative style) from my Piece class

I've been cooking with gas since I got Daniel C Sobral's help on my last question. I am now re-reading Odersky's "Programming in Scala, 2nd Edition" (finished my first reading about this time last ...
2
votes
1answer
132 views

Ideal FP/Scala way to vaildate rectangular list

I am learning Scala and FP (Functional Programming), coming from Java, OO and a strong imperative pardigm. I am now trying to implement a small puzzle solving project so I can get some deeper hands on ...
5
votes
2answers
2k views

Pouring water problem

I just began to study Scala (coming from Python I had quite a few problems with types) and I want to know if my first code to solve a real problem is nicely done or if there is some points that need ...
10
votes
1answer
312 views

OSGi-like infrastructure

I am a moderately new Scala developer working mostly by myself, so I don't have anyone to tell me what I'm doing wrong (except that the system mostly does work, so it can't be too awful). I would ...
5
votes
3answers
384 views

Finding the first stream of non-repeating elements in Scala (without recursion or side-effects)

Here are some examples: [1, 2, 3, 4, 5] => [1, 2, 3, 4, 5] [10, 15, 10, 15, 30] => [10, 15] [1, 2, 3, 4, 1, 5, 6, 7] => [1, 2, 3, 4] Here's my best (and ...
2
votes
1answer
285 views

Scala object-function balance

I am learning Scala, coming from Java background. Here I have written a small prototype proof of concept program that is a part of concept base for a simple upcoming tutorial game. There are two game ...
4
votes
1answer
714 views

Functionally retrieving rows from a database in Scala

Consider the following piece of code: ...
2
votes
1answer
280 views

Scala Direction enum with Enumeration and collection usage

I've just implement direction enum ...
1
vote
1answer
419 views

Simple factory pattern in scala (attempting to restrict use of new)

I am a Scala newbie and attempting to improve my skills. I have decided to be playful about it and work to do a conversion of the spaceinvaders game supplied with the LWJGL. It consists of 10 Java ...
3
votes
2answers
2k views

Checking if two byte arrays are the same

I have a method to compare two byte arrays. The code is Java-style, and there are many if-elses. ...
8
votes
1answer
265 views

Basic XML template

I am currently exploring the play framework. I'm about to replace the proposed templating system, using the powerful XML processing of the Scala library. Here is what I have come with: ...
2
votes
3answers
429 views

Correct use of Option in scala?

I'm somewhat new to Scala and am not sure if I'm doing things in a very Scala-esque way. In particular, I'm not sure if I'm using Option correctly, since by ...
7
votes
5answers
7k views

More functional way of writing this palindrome extractor?

I wrote this palindrome extractor. And even though it works, and I can solve the challenge with it, it feels very Java-like. I was wondering what adjustments I could make in order for it to be more ...
2
votes
1answer
394 views

Formatting as a table in Scala

I'm trying to get my head in the Scala game, and would welcome feedback on the following code, which produces a table from data. ...
6
votes
1answer
688 views

Conway life game implementation with scala

I've tried to create optimal in terms of performance and memmory consumption. But also I've tried to make it functional and scala way. I want to get you comment on how to make it more 'scala'stic <...
0
votes
1answer
661 views

Composite Design Pattern in Scala

The following is a personal attempt at implementing the Composite design pattern in Scala. Observation is abstract... ...
6
votes
3answers
3k views

FSA (finite state automaton) in Scala

I'm a beginning Scala programmer with a strong background in functional programming (ML, Haskell, Scheme) and I've just written my first Scala program. It is an implementation of a FSA (finite state ...
5
votes
1answer
564 views

Processing XML configuration which stores regular expressions and format strings for a documentation tool

I'm investigating some feature for the ScalaDoc tool, which would allow library writers to link to documentation created by third party tools like JavaDoc. My idea is to have some (XML) configuration ...
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. ...
3
votes
1answer
427 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: ...
5
votes
2answers
228 views

Checking a collection of Ints

I'm learning a little Scala by writing a little card game. What I want to do here is check that the Traversable[Team] supplied has the same number of team members ...
5
votes
2answers
854 views

Producing full list of Fibonacci numbers which fit in an Int

I am progressing through the problems listed at projecteuler.com as I learn Scala (my blog where I am covering this experience). I have written a function to produce all the Fibonacci numbers possible ...
2
votes
2answers
220 views

Scala list folding

I'm trying to learn scala. It's hard. I currently have a tree in the form class Node(children:List[Node], value:Int){ } I want to calculate a total cost ...
5
votes
3answers
428 views

Decided to learn Scala. Here's an attempt at a Cloth simulation

I have never done anything functional before. These two functions are hideous to look at. II think the first step to do is extract the inner bits out and then map over my arrays. What else can I do to ...
2
votes
2answers
573 views

Scala mastermind solver, which is the most scala-ish

I am trying to express the classical TDD kata of mastermind in the most idiomatic scala I can. Here is a scalatest, test suite : ...
3
votes
3answers
510 views

Alien Numbers - how Scala-ish is my solution?

I'm trying to solve an old GCJ. It's a very simple puzzle, but I'm trying to sharpen my Scala-fu. Basically, you're getting a list of triple ...

1
6 7 8 9
10