Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6870857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:44:04+00:00 2026-05-27T03:44:04+00:00

I have been reading many articles trying to understand the difference between functional and

  • 0

I have been reading many articles trying to understand the difference between functional and logic programming, but the only deduction I have been able to make so far is that logic programming defines programs through mathematical expressions. But such a thing is not associated with logic programming.

I would really appreciate some light being shed on the difference between functional and logic programming.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:44:04+00:00Added an answer on May 27, 2026 at 3:44 am

    I wouldn’t say that logic programming defines programs through mathematical expressions; that sounds more like functional programming. Logic programming uses logic expressions (well, eventually logic is math).

    In my opinion, the major difference between functional and logic programming is the “building blocks”: functional programming uses functions while logic programming uses predicates. A predicate is not a function; it does not have a return value. Depending on the value of it’s arguments it may be true or false; if some values are undefined it will try to find the values that would make the predicate true.

    Prolog in particular uses a special form of logic clauses named Horn clauses that belong to first order logic; Hilog uses clauses of higher order logic.

    When you write a prolog predicate you are defining a horn clause:
    foo :- bar1, bar2, bar3. means that foo is true if bar1, bar2 and bar3 is true.
    note that I did not say if and only if; you can have multiple clauses for one predicate:

    foo:-
       bar1.
    foo:-
      bar2.
    

    means that foo is true if bar1 is true or if bar2 is true

    Some say that logic programming is a superset of functional programming since each function could be expressed as a predicate:

    foo(x,y) -> x+y.
    

    could be written as

    foo(X, Y, ReturnValue):-
       ReturnValue is X+Y.
    

    but I think that such statements are a bit misleading

    Another difference between logic and functional is backtracking. In functional programming once you enter the body of the function you cannot fail and move to the next definition. For example you can write

    abs(x) -> 
       if x>0 x else -x
    

    or even use guards:

    abs(x) x>0 -> x;
    abs(x) x=<0 -> -x.
    

    but you cannot write

    abs(x) ->
       x>0,
       x;
    abs(x) ->
       -x.
    

    on the other hand, in Prolog you could write

    abs(X, R):-
       X>0,
       R is X.
    abs(X, R):-
       R is -X.
    

    if then you call abs(-3, R), Prolog would try the first clause, and fail when the execution reaches the -3 > 0 point but you wont get an error; Prolog will try the second clause and return R = 3.

    I do not think that it is impossible for a functional language to implement something similar (but I haven’t used such a language).

    All in all, although both paradigms are considered declarative, they are quite different; so different that comparing them feels like comparing functional and imperative styles. I would suggest to try a bit of logic programming; it should be a mind-boggling experience. However, you should try to understand the philosophy and not simply write programs; Prolog allows you to write in functional or even imperative style (with monstrous results).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading so many topics here about this, but I could not
I have been reading the many posts on this topic and have been trying
I am completely new to Android development and have been reading many articles on
I have been reading many posts that describe my problem but I cannot find
I have been reading about the differences between Table Variables and Temp Tables and
I have been reading up on multiple PHP frameworks, especially the Zend Framework but
I have been reading up and trying Git for the last few days and
I have been reading numerous books on iPhone development and doing the examples but
I'm trying to wrap my brain around JMS and have been reading up on
I have been reading around for other answers but i am still not understanding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.