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
2
votes
1answer
279 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
426 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
370 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
672 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
642 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
561 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
421 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
823 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
209 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
426 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
565 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
508 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 ...