Mathematical Operations and Logic

FresherVerism avatar
FresherVerism
·
·
Download

Start Quiz

Study Flashcards

25 Questions

What is the super class of the dept class?

student

What is the name of the instance created from the student class?

ahmed

What is the group of the instance y2?

two

What is the age of the instance y1?

44

What is the purpose of the 'unmake-instance' function in the rule?

To delete an existing instance

How do you modify an instance in the given example?

Using the 'modify-instance' function

What is the department name of the instance y3?

it

What is the purpose of the 'defrule delete' rule?

To delete an existing instance

What is the mode 'r' used for when opening a file?

Read access only

What is the syntax to create a new instance of a class 'student'?

(make-instance [c1] of student (name ahmed) (age 25))

What is the notation for the mathematical operation 2 multiplied by 2?

(* 2 2)

Which of the following notations represents the operation 4 divided by 2?

(/ 4 2)

What is the notation for the equality operation where both sides are the same?

(eq a a)

What is the result of the operation (neq a A)?

FALSE

What is the notation for the greater than operation?

(> 4 3)

What is the length of the string 'a b c d'?

4

What is the result of the expression (str-cat 'Micro ' 'Computer')?

Micro Computer

What is the purpose of the sub-string function?

To retrieve a portion of a string from another string

What type of data is returned by the str-cat function?

String

What is the main difference between the str-cat function and the sub-string function?

The str-cat function concatenates strings, while the sub-string function retrieves a portion of a string

What is the purpose of the rule 'Readline'?

To read all data lines in the 'd:\text.txt' file

What function is used to check if the end of the file is reached?

eq ?d EOF

What is the purpose of the 'printout t ?d crlf' function?

To print the data to the console

What is the symbol used to open a file in read mode?

"r"

What is the purpose of the Clips format?

To allow the user to send formatted output to a device

Study Notes

Mathematical Operations

  • Mathematical operations in CLIPS can be represented in prefix notation, where the operator is written before the operands.
  • Examples of mathematical operations include:
  • 2*2 => (* 2 2)
  • 4/2 => (/ 4 2)
  • 1+3 => (+ 1 3)
  • 4>3 => (> 4 3)
  • 2=2 => (= 2 2)

String Operations

  • The str-cat function concatenates its arguments into a single string.
  • Example: (str-cat “Micro “ Computer) => “Micro Computer”
  • The length function returns the length of a string.
  • Example: (length “a b c d”) => 4
  • The sub-string function retrieves a portion of a string from another string.

Defining Classes and Instances

  • A class can be defined using the defclass function, which specifies the slots and their types.
  • Example: (defclass student (is-a USER) (slot name) (slot age) (slot address))
  • An instance can be created using the make-instance function, which specifies the class and the values for the slots.
  • Example: (make-instance [y1] of student (name ahmed) (age 44) (address tanta))

Rules

  • A rule can be defined using the defrule function, which specifies the conditions and actions.
  • Example: (defrule r2 => (make-instance [y1] of student (name ahmed) (age 44) (address tanta)) ... )
  • Rules can be used to create instances, print messages, and delete instances.
  • Example: (defrule delete ?inst => (unmake-instance ?inst) (printout t “this instance was deleted “ ?inst crlf))

Modifying Instances

  • An instance can be modified using the send or modify function.
  • Example: (send [c1] put-age 30) or (modify-instance c1 (age 30))

I/O System

  • A file can be opened using the open function, which specifies the file name and mode.
  • Example: (open "d:\text.txt f1 "r")
  • The readline function can be used to read a line from a file.
  • Example: (bind ?d (readline f1)) (if (eq ?d EOF) then (break)) (printout t ?d crlf)
  • The format function can be used to send formatted output to a device.
  • Example: (format t "10tHello, World!%" )

Convert mathematical expressions and logical operations into prefix notation. Test your understanding of basic arithmetic and logical operators.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Prefix Power
3 questions

Prefix Power

ComfortingRevelation avatar
ComfortingRevelation
Prefix Power Quiz
6 questions

Prefix Power Quiz

AffirmativeSalmon avatar
AffirmativeSalmon
Prefix Quiz (Group 5)
8 questions

Prefix Quiz (Group 5)

PleasedFibonacci avatar
PleasedFibonacci
Use Quizgecko on...
Browser
Browser