PPL Unit 6
PPL Unit 6
It avoids changing data and using loops; instead, it uses functions, recursion,
and expressions.
Letter Feature
Pure functions (no side effects): Same input always gives same output, no
P
side effects.
U Uses recursion: Replaces loops using function calls.
R Referential transparency
E Expressions over statements
S Stateless (no variable changes): Doesn’t change external state or variables.
H Higher-order functions: Functions that take or return other functions.
I Immutable data: Variables are not changed once set
Pass functions as arguments (First-class): Functions can be passed as
P
arguments or returned.
Word Feature
Rule Rule-based programming: Uses facts and rules to reach conclusions.
Based Backtracking supported: Tries all possible options to find a solution.
People Pattern matching: Matches input data with known rules.
Formal logic-based (declarative style): Describes what to do, not how
Find
to do it.
Smart Symbolic computation: Works with symbols instead of numbers only.
Automatic inference engine: Solves queries using logical inference
Answers
engines.
🔹 2. List-Based Language:
🔹 3. Dynamic Typing:
🔹 5. Recursion Support:
Explanation:
Recursive version: multiplies base with itself exp times using function
calls.
Example Call:
Answer:
1. CAR(): car is a LISP function that returns the first element of a list.
2. CDR(): cdr returns the rest of the list after removing the first element.
Example:
Q.8)
Q.*
Answer:
The functor is the structure name, and arguments can be constants, variables,
or other structures.
head :- body.
Or simply:
fact.
Example:
sun_rises_in(east).
likes(john, pizza).
Example:
happy(X) :- rich(X).
Example:
?- likes(john, pizza).
Output: true