Tagged Questions
4
votes
2answers
137 views
Merge sort in scala
I've implemented merge sort in scala:
object Lunch {
def doMergeSortExample() = {
val values:Array[Int] = List(5,11,8,4,2).toArray
sort(values)
printArray(values)
}
def ...
4
votes
3answers
173 views
A scala implementation of java trim method
I'm a scala beginner and looking at the trim() method of the java api I noticed side effects, so I attempted to implement a functional version in scala.
Here is the java version :
public String ...
4
votes
1answer
81 views
Scala: how to find and return a loopy path in a directed graph
I wrote a function in Scala to find out and return a loopy path in a directed graph. The program is as followed, one of the arguments is a graph presented in an adjacent list, and the other is a start ...
2
votes
1answer
160 views
Scala: tail-recursive factorial
Is there anything what could be improved on this code?
def factorial(n: Int, offset: Int = 1): Int = {
if(n == 0) offset else factorial(n - 1, (offset * n))
}
The idea is to have tail-recursive ...
2
votes
4answers
581 views
Is my Scala Option conversion to Java correct?
Summary:
I've implemented what I think is a complete Java implementation of the Scala Option class. Could you please review and let me know if I have correctly and completely implemented it? And if ...
3
votes
2answers
239 views
How to improve this scala code which is checking if two byte arrays are same?
I have a method to compare two byte arrays. The code is java-style, and there are many "if-else"s.
def assertArray(b1: Array[Byte], b2: Array[Byte]) {
if (b1 == null && b2 == null) return;
...
2
votes
0answers
242 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
2answers
277 views
Producing full list of Fibonacci numbers which fit in Int…
I am progressing through the problems listed at projecteuler.com as I learn Scala (my blog where I am covering this experience: fromjavatoscala.blogspot.com). I have written a function to produce all ...