All Questions
Tagged with scalafunctional-programming
104 questions
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 ...
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 ...
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))") -> ...
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 ...
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 ...
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 ...
6votes
2answers
574views
Improving my Tic Tac Toe Solution in Scala
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 ...
3votes
1answer
230views
Improvements, TicTacToe in Scala
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 ...
3votes
1answer
70views
Scala: Cumulative String Tokenisation
I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below, ...
2votes
0answers
187views
generic implementation approaches for a recursive function
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 ...
2votes
0answers
60views
Finite automaton library in Scala including subset construction and minimization
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, ...
-1votes
1answer
59views
Functional filter unique elements in sequence is not as good as imperative [closed]
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 ...
1vote
1answer
310views
Provide functional-programming style solution for 2D Array - DS challenge
Problem Statement: Given a 6×6 2D Array, arr: 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in A to be a subset of ...
3votes
2answers
401views
Count character 'a' in first n characters of indefinitely repeating string s
Problem statement: Lilah has a string, s, of lowercase English letters that she repeated infinitely many times. Given an integer, n, find and print the number of letter a's in the first n ...
5votes
2answers
308views
Counting valleys traversed below sea level, given elevation changes
Problem Statement: Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step he ...