Skip to main content

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.

1vote
0answers
30views

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 ...
TorbenPutkonen's user avatar
2votes
1answer
35views

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 ...
bynux's user avatar
4votes
7answers
279views

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 ...
vikrant's user avatar
2votes
1answer
91views

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 ...
L68967gy's user avatar
3votes
1answer
109views

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 ...
AminMal's user avatar
1vote
1answer
724views

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 :...
Imed 's user avatar
1vote
0answers
40views

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 ...
Zhao Li's user avatar
1vote
2answers
81views

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 ...
Jonathan Spiller's user avatar
3votes
2answers
1kviews

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))") -> ...
Julian Espinel's user avatar
2votes
0answers
116views

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 ...
user's user avatar
  • 529
1vote
1answer
93views

Checking whether a graph is connected in an immutable way

I have this function at the moment ...
bigfocalchord's user avatar
2votes
3answers
124views

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 ...
Filipe Miranda's user avatar
2votes
0answers
130views

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 ...
Andrey Tyukin's user avatar
3votes
1answer
319views

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 ...
Martin Boros's user avatar
4votes
1answer
160views

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, ...
Dahiben Kumar's user avatar

153050per page
close