 LISP and PROLOG Questions

Subject Computer Science Computer Science - Other

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 \$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 \$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 \$30.00
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 \$88.00
Computer Science
Programming
Algorithms
C
Structures
CSV Files
Pointers
Loops
Arrays
File Management
Variables
Statements
Input
Output
Tables
Memory Allocation
Strings
Integers
Database Management Questions \$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 \$50.00
Programming
Shell
Telephone Book
Users
Inputs
Outputs
Scripts
Commands
Names
Numbers
Do-While
Loops
Conditions
Search Fields
Live Chats