Questions tagged [logic-programming]

20 questions
218
votes
18 answers

How can one manage thousands of IF...THEN...ELSE rules?

I am considering building an application, which, at its core, would consist of thousands of if...then...else statements. The purpose of the application is to be able to predict how cows move around in any landscape. They are affected by things like…
20
votes
2 answers

How to implement interactive programs (like games/simulations) using logic programming?

I've heard that logic programming can serve as a general-purpose alternative to other programming paradigms such as OO or functional programming. (Since Prolog is Turing-complete, this must be so!) However, I'm having trouble seeing how one would…
Alex D
  • 1,308
  • 9
  • 14
15
votes
1 answer

Is the Mercury Programming Language used in the field?

I've strong interests in Functional and Logic programming and Mercury seems like a good blend of the two. Is it used in industry at all? I'm one to learn a language just for the fun of it but it would nice to have practical, employable avenues for…
12
votes
3 answers

Why (not) logic programming?

I have not yet heard about any uses of a logical programming language (such as Prolog) in the software industry, nor do I know of usage of it in hobby programming or open source projects. It (Prolog) is used as an academic language to some extent,…
Anto
  • 11,157
  • 13
  • 67
  • 103
9
votes
2 answers

How would I combine 'Command' and 'Composite' to simulate a time delay?

As a learning exercise (I am not in school - just an old guy trying to learn something new), I am trying to write a logic gate simulation that incorporates propagation delay. The user should also be able to group gates together to create…
8
votes
8 answers

AND is better or using Internal "IF"

In a situation like this:" if ((metadata != null) && (metadata.TypeEnum != VariantInfoMetadata.CellTypeEnum.Status)) do you recommend to keep the code as it is above? Or is it better to make a nested "if" statement and breaks the condition into…
Blake
  • 839
  • 2
  • 8
  • 17
7
votes
4 answers

Data Structures to represent logical expressions

Here is a logical statement: term1 AND (term2 OR term3) OR term4 What is an effective way of storing this information in a data structure? For example, should I use a graph, with a property on each edge defining the operator to the next term? (This…
Trindaz
  • 195
  • 1
  • 5
5
votes
3 answers

Is saying "if ( $a != null && $a == 5)" the same as "if ($a == 5)"

First off, sorry if this is answered somewhere else. I did a brief search, but wasn't sure how to ask in search terms. I'm looking at some code and came across lot's of statements like this: if ( ($a != empty_or_null_or_notDefined && $a == 5 ) Is…
user127379
  • 361
  • 2
  • 8
4
votes
1 answer

Multivariable decisions

I am running into a situation where my program can have different outcomes depending on the state of some variables. 4 variables are involved and they can all have different ( 3 to 4 different states). All the possible combinations are leading me to…
mbashir
  • 143
  • 3
3
votes
1 answer

Good introduction to metaprogramming in Prolog?

I would like to make for example imperative programs as output of Prolog (shaders of graphic card) and also event-driven programs (game logic) ... also I would like to learn how to metaprogram in Prolog in general. I believe there might be some…
user712092
  • 1,412
  • 10
  • 18
3
votes
3 answers

Scheme and Functional programming is to "Structure and Interpretation of Computer Programs" as Prolog and Logic programming is to what book?

I'm looking for some advice how to get started with Logic programming, and I am really enjoying working through the Scheme book "Structure and Interpretation of Computer Programs." Is there a similar book that is geared toward Prolog? Or, if there…
2
votes
3 answers

Logic Programming(Unification) vs List Comprehensions (in Functional Programming)

I found this answer on StackOverflow very clear to explain the difference beween the Logic Programming paradigm and the Functional Programming paradigm: The thing that makes logical append different [from the functional one] is you can use it to…
Qqwy
  • 4,709
  • 4
  • 31
  • 45
2
votes
0 answers

What makes the functional and logic programming paradigms well suited for programming AI?

I have been researching different programming paradigms. I have found a lot of people saying that one of the areas where logic and functional programming are particularly good is programming AI, but I am having a hard time finding a good explanation…
2
votes
1 answer

Given a situation, and some conditions, verify is that situation is possible

Well it's a problem me and my friend had thought of, and well, haven't come up with anything to solve the following problem(I'll try to phrase it in the best way I can): Given that there are n number of teams, and the number of matches each team…
pradyunsg
  • 245
  • 2
  • 12
1
vote
1 answer

How to use Try/catch and database transaction in PHP and laravel

I'm planing to use Try/Catch and Database Transaction in Laravel5 and my own PHP project to validate any errors occurs then rollback avoiding lost my transaction or information during user do their transaction to Database. I'm sure to find out if…
Heng Sopheak
  • 123
  • 1
  • 1
  • 6
1
2