All Questions
Tagged with scala immutability
7 questions
3
votes
2
answers
401
views
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 ...
5
votes
2
answers
308
views
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 ...
2
votes
1
answer
438
views
Functional API wrapper written in Scala
I've been working on an small API wrapper for the GitHub API using Scala (full source on GitHub). I'm still very new to the language, so I was hoping to get some feedback about a couple of design ...
2
votes
2
answers
614
views
A Scala Maze Generator in Functional Style
I'm wondering if there is more I can do to incorporate more idiomatic scala and functional programming principles. I know the maze itself is mutable but i didn't see an easy solution to making it ...
2
votes
1
answer
100
views
Building and querying an immutable phone book
I wanted to get your opinion on this immutable implementation of a Phone Book using recursion to process a stream. I am especially interested in ways to speed up the code execution.
Here is an ...
5
votes
3
answers
128
views
Generating a game board with squares in a rectangle
I am trying to generate a game board (similar to a Monopoly board). I am new to Scala and am thinking that there may be a better way to do this. But improvements to the code are also welcome.
...
3
votes
1
answer
191
views
Functional SaveObject in Scala
I came across Java like Scala code that I am trying to refactor to make it functional and immutable. The first obvious flaw is that it's violating thread safety by using mutable public class level ...