Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 27679

Add this tag to your question to indicate that you are new to the language of your code. This will often be taken into consideration by reviewers when assessing your code.

6 votes

"Hello world!" in Prolog

Why fail at all? Isn't success better than failure? A shorter version is thus: main :- writeln('Hello world!'). Also, why even have side effects? Isn't a declarative solution much better: message( …
mat's user avatar
  • 706
3 votes
Accepted

Iterating towards a goal

Executive summary: please_use_very_readable_names insteadOfUnreadableOneslikeInJava. Use higher-order predicates. Always consider using DCGs when describing lists. pass1 and pass2 can be simplified …
mat's user avatar
  • 706
2 votes
Accepted

Implementing an open/close function in Prolog

Always try hard to avoid assert/1 and retract/1: Using these predicates makes it impossible to reason about your other predicates in isolation, and therefore make debugging and extending your code muc …
mat's user avatar
  • 706
2 votes
Accepted

Binary Digits to ASCII Characters

Your concerns about style and format are warranted, +1 for striving to make the code more elegant and declarative! First of all, whatDoYouFindEasierToRead: mixed_caps_or_underscores? For that reason …
mat's user avatar
  • 706
1 vote

Aggregate cost for a directed graph in Prolog

Using global variables is a sure sign that you are not working within the declarative paradigm. A declarative way to solve this is to keep track of the already visited variables via an argument of you …
mat's user avatar
  • 706
1 vote

Adding elements in two lists as numbers

When describing lists, always consider using DCGs. In this case, try for example: sum(Xs0, Ys0, Ls) :- reverse(Xs0, Xs), reverse(Ys0, Ys), phrase(sum(Xs, Ys, 0), Ls0), reverse(Ls0, Ls …
mat's user avatar
  • 706