New answers tagged functional-programming
1
step does two things: (1) step to the next state, and (2) check that the state is valid. Its name suggests only the first meaning. The repetition of wrapValidInJust suggests that they can be separated.
Instead of == you can use pattern-matching.
isgood :: String -> Bool
isgood = isValidFinal . foldM (check . step) (0, 0)
where
step (x, y) 'R' = (...
1
First off, what you currently have is perfectly fine. The only thing I would suggest is to use pathlib.Path instead of manually using format and consistently follow the PEP8 naming scheme by using lower_case and having spaces after commas in argument lists:
from pathlib import Path
file_name = Path(f).with_suffix(".txt")
I see two ways you could ...
1
The default behavior of array_filter() is greedy about destroying falsey values.
$new_query = array_filter($new_query, function($element) { return !empty($element);});
is identical in functionality to:
$new_query = array_filter($new_query);
I recommend consistently using curly braces on all constructs and logical tabbing to make your code more readable.
...
Top 50 recent answers are included
Related Tags
functional-programming × 943javascript × 267
programming-challenge × 108
python × 106
scala × 104
f# × 78
haskell × 75
algorithm × 72
beginner × 67
ecmascript-6 × 59
c# × 49
performance × 47
python-3.x × 46
recursion × 45
java × 42
c++ × 42
clojure × 37
strings × 31
object-oriented × 29
comparative-review × 29
array × 20
lisp × 19
parsing × 18
immutability × 18
game × 17