Questions tagged [immutability]
Immutability is the inability to modify data after it has been created. Modifications are instead made by copying the data. A property of immutable data is that it is *referentially transparent*.
80 questions
6 votes
1 answer
932 views
Python function that deeply "freezes" an object
I implemented a function that gets an object and returns its immutable counterpart. If the object contains another mutable object at any level, it freezes it too. Is my code is good and/or can it be ...
4 votes
1 answer
135 views
Lift simulator in Java
I implement a working version of the Lift Kata Can you provide me some tips to improve my code? I am not very proud of the handleLiftWithOpenDoors method that have ...
3 votes
1 answer
272 views
Implement a Python frozenmap
There are frozenset in Python, but no frozendict or frozenmap. I tried to implement it (Don'...
2 votes
1 answer
131 views
Immutable interpreter in C++
I am writing an immutable interpreter in C++ for fun. Originally standard vectors and dequeues were used to create a double ended queue data type, but it was very slow, because each operation require ...
2 votes
1 answer
356 views
A new CHAMPion - Compressed Hash-Array Mapped Prefix-tree in C
I implemented an immutable hash map in C, as described in this paper. First, my design goals: plug-and-playable: compile with gcc -O3 -std=c11 champ.c, ...
2 votes
0 answers
36 views
Set values with keeping immutability in React FC
I'd like to know there's a better code than I did. interface AnswerProps{ itemId: string; value: Array<string> } This code works like checkbox. If <...
8 votes
2 answers
389 views
Immutable builder and updater
There aren't enough questions about creating immutable objects... so why not try it again with another approach. This time, it's a builder that maps properties to constructor parameters. Properties ...
7 votes
1 answer
240 views
Quicksort in JavaScript assuming an immutable array
Update: further succinct versions below (inspired by Haskell) Quick sort in JS assuming an immutable array: ...