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.
494 questions
1
vote
0
answers
30
views
Evaluating an expression with shunting yard algorithm
I'm learning Scala and wrote a simple infix expression evaluator using the shunting yard algorithm. As opposed to the wikipedia example, this implementation evaluates the expression in place instead ...
2
votes
1
answer
35
views
Created a Scala (Native-compatible) program that scores words in Scrabble. Any refactor tips?
As said in the title, I used Scala to make a simple little program that takes a formatted input string representing a word in Scrabble and spits out its score, including a message explaining where the ...
4
votes
7
answers
279
views
Breaking a string expression in operator and operands
Requesting for a code review for a scala implementation.
Problem
Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
2
votes
1
answer
91
views
Tic Tac Toe on the command line in Scala
This is my first Scala program, so I'd appreciate any feedback but especially feedback specific to Scala, for example situations where I could have utilised a feature better or where I've done ...
3
votes
1
answer
109
views
Batching method implementation - Scala
I need to implement a function/method that operates on a sequence of values, and acts kind of like takeWhile, but with 2 differences, first, it doesn't act on a single element, it is performed on a ...
1
vote
1
answer
724
views
Get tennis game's state using scala
I am developing a scala function called TennisGameStatus which returns the state of tennis games between two players.
To remind, here are the rules of tennis games :...
1
vote
0
answers
40
views
Relational join of two datasets
Front Matter
I'm learning Scala and have not gotten used to functional programming and the language. I'm hoping a review of my naively implemented code can help me bridge my object-oriented ways to ...
1
vote
2
answers
81
views
Extracting items from comma/semicolon-delimited strings, discarding parts after a hyphen
New Scala dev here. Is there a more idiomatic or efficient way to accomplish this in Scala?
Given a list of the following strings, I need to obtain the unique 'main parts' once any parts including ...
3
votes
2
answers
1k
views
Scala Parentheses Balancing in Functional Programming
I was working on the problem to check if the parenthesis are balanced using Scala.
Examples:
balance("(Hello (my) name is (StackOverflow))") -> ...
2
votes
0
answers
116
views
Deserialize a binary tree breadth-first in functional programming
A while back, I answered this question on Stack Overflow that involved deserializing a binary tree breadth-first using functional programming (the question itself isn't relevant). I'd like to make ...
1
vote
1
answer
93
views
Checking whether a graph is connected in an immutable way
I have this function at the moment
...
2
votes
3
answers
124
views
Is My Function to Find Triplets in Scala running in O(N^2)
Given the classical problem to find triplets that sum to zero in an array. Is my Scala implementation correct and executed in O(N^2)? If yes, why? Can someone make a running time analysis.
What other ...
2
votes
0
answers
130
views
Scala 3 Typeclass derivation using low-level mechanisms: The `Eq`-example
I've been playing around with this example from the Scala 3 documentation, and I noticed that certain things duplicate functionality already present in the standard API; In particular, the ...
3
votes
1
answer
319
views
Efficiently calculate value of Pascal's Triangle using memoization and recursion
So reading about functional programming, applications to dynamic programming, and learning Scala. I figured I would try it out with a popular example, Pascal's Triangle, tests against known values ...
4
votes
1
answer
160
views
Improving Mancala Game
https://www.mastersofgames.com/rules/mancala-rules.htm
I am trying to create a working Mancala Game in scala, Currently, I have 3 classes, Board, ...