Question

* Describe briefly the working principles of LISP.

* Describe briefly the working principles of PROLOG.

* Write both a LISP program and PROLOG program for the following problems
a) find the length of a list
b) find the average of a list of numbers
c) combine two sorted lists into a sorted list
d) reverse a list.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

Prolog

size([],0).
size([H|T],N) :- size(T,N1), N is N1+1.

reverse(L, R) :-
          reverse2(L, [], R).

reverse2([], R, R).
reverse2([H|T], O, R) :-
          reverse2(T, [H|O], R).


sum([],0).
sum([X|L],N):-sum(L,N1),N is X+N1.

average([],0).
average(L,X):-sum(L,S), size(L,N), X is S/N.

merge( [], RS, RS ).
merge( LS, [], LS ).
merge( [L|LS], [R|RS], [L|T] ) :- L =< R, merge(    LS, [R|RS], T).
merge( [L|LS], [R|RS], [R|T] ) :- L > R, merge( [L|LS],   RS, T)....

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Web Services for Data Science Applications (540 words)
Homework Solution
$25.00
Computer Science
Web Services
Data Science
Big Data Analytics
Developers
Machine Learning
Intelligence
Tensor Flow
Video Processing
Financial Applications
Images
Cloud
Microsoft Azure
AWS
Bigml
C++ Questions
Homework Solution
$30.00
Programming
C++
Palindromes
Strings
Reverse Functions
Time Formats
Parameters
Outputs
Console
Input
Output
Display
Letters
Characters
Lines
Statements
Variables
Counters
Architecture Firm Discussion (630 words)
Homework Solution
$18.00
Architecture Firm
Computer Science
IT Information
Companies
Departments
Infrastructure
Business
Supply Chain
Critical Functionality
Asset Assessment
Database Management
Security Measures
Productivity
Performances
Threats
Clients
Guess a Word Game in C#
Homework Solution
$40.00
Computer Science
C# Programming
Game Development
Guessing
Words
Letters
Randomization
Buttons
Startup Tasks
Game Interface
Functions
Statements
Variables
Crime Scene Investigation Protocols (220 words)
Homework Solution
$10.00
Technology
Computer Science
Crime Scene
Investigation Protocols
Beaches
Underwater
Metal Detectors
Erosion
Storms
Oceans
Lifeguards
Precision
Blood
Evidences
Personal Budget Using Microsoft Excel
Homework Solution
$50.00
Business
Personal Budget
Microsoft Excel
Wages
Interest
Daily Living
Expenses
Worksheets
Transportation
Entertainment
Housing
Utilities
Get help from a qualified tutor
Live Chats