New answers tagged

5 votes

Implementing a --assume-yes/--assume-no command line flag to affect a `input()` based `confirm()` function

Don't assign to args within the __main__ guard - it's still global; it needs to be moved to a function. ...
Reinderien's user avatar
  • 58.1k
6 votes

Implementing a --assume-yes/--assume-no command line flag to affect a `input()` based `confirm()` function

Of the three approaches, the first seems best to me. We can do a little better by giving names to the the "assume" versions of the function, and include them in ...
Toby Speight's user avatar
3 votes

Comparison of Named parameters and the Java Builder pattern in C++

Named parameters are less extensible The named parameters approach looks nice, as it is a language feature. However, it requires C++20, only works on aggregates, and if you ever want to add more ...
G. Sliepen's user avatar
  • 49.3k
0 votes

maxlist(L, M) that succeeds if M is the max number in the list L

If you change the first clause to maxlist2([N], N) :- !., the extra choice point disappears. Your implementation does not recognize the fact that the two clauses ...
Will Ness's user avatar
  • 1,006

Top 50 recent answers are included