Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
0 answers
71 views

Immutable-Object-like Structure in PHP

I made a closure-based PHP structure that behaves mostly like a classical object. To change the object's state, one must derive a new copy by passing the altered state to the ...
Benni's user avatar
  • 153
3 votes
2 answers
412 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 ...
Sandio's user avatar
  • 119
6 votes
2 answers
323 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 ...
Sandio's user avatar
  • 119
3 votes
1 answer
2k views

Rust: Flattening nested struct to Vec<T>

I have a struct which nests other structs like following: ...
philipjkim's user avatar
4 votes
1 answer
215 views

Lock-free Immutable ConcurrentQueue

Similar to the code review I posted last week for an agent-based immutable replacement for ConcurrentDictionary, I have also created an agent-based immutable ...
Aaron M. Eshbach's user avatar
7 votes
0 answers
128 views

Agent-based Immutable Map

I am in the process of removing the last few pieces of mutable state from an F#-based distributed system. Some of the remaining mutable state is a ...
Aaron M. Eshbach's user avatar
3 votes
1 answer
1k views

Implement array element swap in a functional language

Sorting algorithms involve swapping element positions in an array. This is my implementation of swap: ...
Shaun Luttin's user avatar
2 votes
1 answer
458 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 ...
MattDs17's user avatar
  • 225
12 votes
1 answer
371 views

Cat fight (with rockets)

My code is attempting to implement FP in an efficient / readable manner into some of my video games. I realize this may be a bit subjective, but I feel there is enough merit / objectivity to be of ...
Fluidity's user avatar
  • 228
2 votes
2 answers
643 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 ...
j will's user avatar
  • 155
5 votes
3 answers
135 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. ...
Can't Tell's user avatar
4 votes
1 answer
202 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 ...
user2066049's user avatar
4 votes
1 answer
948 views

Functional linked list

I've been implementing functional linked lists in different languages, just as a learning exercise. I'm looking for feedback in general: code correctness, best practices, design patterns; everything ...
NPN328's user avatar
  • 771
5 votes
1 answer
955 views

Immutable C++ stack - thoughts and performance

What are your thoughts on the fallowing immutable stack implementation? It is implemented having as a basis a C# immutable stack (where garbage collector assistance does not impose using a reference ...
Ghita's user avatar
  • 151