Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

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
1 vote
0 answers
42 views

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
2 votes
1 answer
46 views

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
  • 215
4 votes
7 answers
317 views

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
  • 405
2 votes
1 answer
104 views

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
3 votes
1 answer
120 views

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
  • 133
1 vote
1 answer
757 views

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
  • 11
1 vote
0 answers
60 views

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
  • 111
2 votes
2 answers
123 views

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
3 votes
2 answers
1k views

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
2 votes
0 answers
129 views

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
  • 539
1 vote
1 answer
116 views

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

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
2 votes
0 answers
140 views

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
3 votes
1 answer
348 views

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

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
0 votes
1 answer
2k views

I am trying to understand the best way to write this. This is part of my organization work so can't disclose it fully here like why such requirement. So Apologies for that. I have ListA and ListB. <...
Ashish Mishra's user avatar
1 vote
2 answers
1k views

I created the following function, permutations, to produce all permutations of a List[A]. Example: ...
Kevin Meredith's user avatar
1 vote
1 answer
184 views

Given a smaller strings and a bigger string b, design an algorithm to find all permuta­tions of the shorter string within the longer one. ...
Kevin Meredith's user avatar
1 vote
2 answers
84 views

I am pretty newbie in Scala, my background expertise is basically Java and Python, and I'd like to know your thoughts about this code snippet written in Scala to know if this is a "regular piece ...
David Martinez's user avatar
1 vote
1 answer
176 views

The following is a trimmed-down example of my actual code, but it suffices to show the algorithmic problem I'm trying to solve. Given is a DataFrame with events, each with a user ID and a timestamp. <...
Tobias Hermann's user avatar
1 vote
1 answer
717 views

I would like to get feedback on my code for Stack implementation written in scala. What can be improved to make it more like scala code. What important helper functions am i missing? ...
Ankush Singh's user avatar
3 votes
3 answers
2k views

I have two optional strings, any of them can be None. I want to create their combination with a delimiter between them if they both exist. I expect to be able to come with a more concise and nicer ...
Suma's user avatar
  • 238
2 votes
1 answer
450 views

Can I reduce the loop inside my method with map or is there a shorter implementation of this code that's dropping elements in sequence? ...
James Flash's user avatar
2 votes
0 answers
52 views

The prompt is as follows: This script will use a text menu to give the user options. The options will include the ability to add grades of different types as well as an option to print the current ...
Asjal Ahmad's user avatar
2 votes
1 answer
97 views

I have the below function which populates different time-related case classes based on what is present in the JSON input. ...
Zzrot's user avatar
  • 121
3 votes
0 answers
264 views

Description I've created simple SBT plugin which enables creating Helm Charts The main reasons: in Helm it is impossible to 'fetch' external files: https://github.com/helm/helm/issues/3276 which is ...
lakier's user avatar
  • 139
4 votes
1 answer
218 views

I need help in rewriting my code to be less repetitive. I am used to coding procedural and not object-oriented. My scala program is for Databricks. how would you combine cmd 3 and 5 together? Does ...
Dung Tran's user avatar
  • 143
6 votes
2 answers
603 views

I'm relatively new to Scala and made a small TicTacToe in a functional Style. Any improvement options would be highly appreciated. There are some things which I am unsure of if they are made in an ...
elauser's user avatar
  • 179
3 votes
1 answer
261 views

I've just started my journey into functional programming and tried to implement a TicTacToe game Recursively without State in Scala. What I dislike is the JOptionPane but I don't know if i can solve ...
elauser's user avatar
  • 179
4 votes
1 answer
212 views

I implemented the following function using the matrix object from breeze library. Basically it is just a glorified while loop. The convolution there is extremely ...
gurghet's user avatar
  • 141
2 votes
1 answer
385 views

Here is my implementation of arg max in Scala. q_table_test.txt contains: ...
blue-sky's user avatar
  • 547
2 votes
0 answers
1k views

I've a scenario where 10K+ regular expressions are stored in a table along with various other columns and this needs to be joined against an incoming dataset. Initially I was using "spark sql rlike" ...
Wiki_91's user avatar
  • 43
3 votes
2 answers
584 views

I have a string "abbbbccdddd" and the function should return "a1b4c2d4". This is what I have written in Scala. Iterative-version ...
Fahad Siddiqui's user avatar
3 votes
1 answer
101 views

Below is a case class and a companion object with a method putRecord which adds a new row into Hbase using Put API. This code has some repetitive parts. Is there a ...
guru107's user avatar
  • 131
3 votes
1 answer
92 views

When you write a code in python code people always ask to make it more pythonic. I am not sure if there is a term for scala or not. However, I am pretty sure my following code use one or two scala ...
Gaurang Shah's user avatar
3 votes
1 answer
82 views

I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below, ...
Wiki_91's user avatar
  • 43
0 votes
2 answers
95 views

I am implementing a functionality in Scala to Copy files from one FileSystem to another ...
Gaurang Shah's user avatar
3 votes
1 answer
115 views

I'm fairly new to Scala and I would like to learn it properly. My current task is to create a type to represent a heap, as seen in interpreters: a mapping from addresses in memory to values stored ...
siledh's user avatar
  • 83
2 votes
1 answer
115 views

I want to map functions from my functions library (Map called as chain) to input string str. ...
Gudsaf's user avatar
  • 176
3 votes
1 answer
117 views

I need to generate random text for tests. I do that using alphanumeric characters and some special characters as well. For some special cases, I cannot generate the random text with tags. I have the ...
Tom's user avatar
  • 149
2 votes
1 answer
272 views

I created a small sample project using caliban, akka-persistence and ZIO. I'm not really happy with the wiring code: ...
TobiP's user avatar
  • 100
0 votes
1 answer
131 views

I've implemented atoi function as described in leetcode problem string-to-integer-atoi. I am looking for some feedback on writing this in a more scala native way ...
Bunny Rabbit's user avatar
2 votes
0 answers
207 views

Let's take the famous fibonacci problem as an example but this is a generic problem. Also, taking scala as the language as it's rather feature-rich. I want to know which solution you'd prefer. we all ...
Maths noob's user avatar
1 vote
1 answer
141 views

i have solved this problem https://leetcode.com/problems/find-eventual-safe-states/submissions/ ...
nz_21's user avatar
  • 1,051
2 votes
0 answers
68 views

I built a scanner generator like flex or jflex in Scala for a class last year. Part of this project is a small library for handling and manipulating finite automata. It works completely as intended, ...
LukeG's user avatar
  • 173
-1 votes
1 answer
83 views

Can you please help me fulfill the following? Requirements: Create an iterable with unique elements. Their order should be preserved: a | b | a | c → a | b | c ...
user214187's user avatar
2 votes
0 answers
401 views

I think the part to get shortest path from the cost table got pretty messy. Also can use some tips on how to avoid the extra O(V+E) work checking all edges from source to dest after getting the cost ...
Layman's user avatar
  • 153
1 vote
1 answer
668 views

I am new to Scala. I have been trying to complete an exercise where the ask was as follows: // Write a function isPerfectNumber which takes integer input and returns String output. // It finds if a ...
Nitin4873's user avatar
  • 111
2 votes
0 answers
342 views

The Mongo-Scala Driver (v2.6) currently only supports asynchronous operations, although my use cases often seem to lend themselves well to synchronous reads. This may be to block downstream code ...
schwadan's user avatar
3 votes
1 answer
408 views

tl;dr I tried to write some as general and as feasible as possible code where entities are able to communicate with other entities of the same type or of different types, allowing for the recipient ...
TomPoczos's user avatar

1
2 3 4 5
10