# Tag Info

## 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