New answers tagged string-processing
3
votes
A simple C++ function converting the environment variables in main() to an unordered_map
Structured binding
One point not raised by previous reviews: the code would be cleaner using a structured binding in your loop over the map contents. As well as making the key and value ...
7
votes
Substitute patterns with values from lists
I would prefer to take Iterable[tuple[str, Iterable[str]]] rather than dict[str, list[str]] for two reasons:
...
3
votes
Substitute patterns with values from lists
I'm not comfortable with that mutating pop, even if it is on a copy. Also, why not make the substitution state reusable? In the following style, subsequent calls on the same object will resume ...
4
votes
Substitute patterns with values from lists
Given that the problem states enough replacement values must be provided to the function, it would seem reasonable to catch that IndexError and raise a ...
6
votes
Substitute patterns with values from lists
Tests
It's nice to see that you have included various tests to verify that replace_in_string works as expected.
Docstring
Its great that you have provided a ...
3
votes
Huffman code builder in Java - computing prefix codes for arbitrary (generic) alphabets - Take II
The HuffmanEncoder is not an encoder. It's a builder that constructs the code table for the symbols based on the weights. An encoder would take input and encode it ...
3
votes
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
Minor but, Huffman only has a single n in the name.
But let's move on to how the code words are built, the meat of the algorithm after all.
...
3
votes
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
Style
When I look at your formatting in the following snippet, for some reason you have a newline after the first argument to Double.compare, but this line would be ...
3
votes
A simple method for compressing white space in text (Java) - Take II
Just some remarks.
By providing a capacity: new StringBuilder(textLength) - here a bit extra room, you prevent internal array resizing inside StringBuilder. For ...
Top 50 recent answers are included
Related Tags
string-processing × 29strings × 13
python × 10
java × 10
programming-challenge × 8
algorithm × 6
c++ × 5
compression × 4
c × 2
reinventing-the-wheel × 2
unit-testing × 2
bitwise × 2
c# × 1
python-3.x × 1
parsing × 1
.net × 1
hash-map × 1
console × 1
mathematics × 1
linux × 1
calculator × 1
networking × 1
c++20 × 1
library × 1
ai × 1