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

C++ Questions
Homework Solution
$25.00
Programming
C++
Computer Science
Objects
Variables
Private Members
Functions
Dollars
Cents
Codes
Statements
Complex Numbers
Arithmetic Operations
Data Fields
Input
Output
Points & Distances Using R Programming
Homework Solution
$90.00
Statistics
Mathematics
Computer Science
Computing
R Programming
Functions
Distances
Points
Pairs
Equations
Matrices
Random Values
Statements
Variables
Loops
Presentation on Google File System
Homework Solution
$30.00
Google
FS
Master
Operation
File
System
Interaction
Component
Clustering
Checksum
Fault
Tolerance
Locking
Replica
Rebalancing
Replication
Garbage
State
Atomic
Record
Mutation
Namespace
Architecture
Chunk
GFS
Scalability
Monitoring
Problems Using Programming Language C
Homework Solution
$88.00
Computer Science
Programming
Algorithms
C
Structures
CSV Files
Pointers
Loops
Arrays
File Management
Variables
Statements
Input
Output
Tables
Linked Lists
Memory Allocation
Strings
Integers
Database Management Questions
Homework Solution
$70.00
Database Management
Computer Science
Tables
Queries
Hotel for Pets
Models
Relationships
Owners
Insurance Values
Primary Key
Lists
MS Access
Telepehone Book Shell Program
Homework Solution
$50.00
Programming
Shell
Telephone Book
Users
Inputs
Outputs
Scripts
Commands
Names
Numbers
Do-While
Loops
Conditions
Search Fields
Get help from a qualified tutor
Live Chats