跳到主要内容

考前速记

Prolog

% Fact (lowercase, dot)
likes(john, apple).

% Rule (:- = IF, , = AND)
happy(X) :- likes(X, apple), sweet(apple).

% Query (?- = ask)
?- happy(X).

OOP Keywords

ConceptMeaning
CLASSTemplate for objects
NEWConstructor
PRIVATEEncapsulation (hide data)
EXTENDSInheritance
OverridePolymorphism

RPN Stack Evaluation

Token | Stack
3 | [3]
4 | [3,4]
+ | [7]
2 | [7,2]
× | [14]

a b - = a − b (NOT b − a) ⚠ a b / = a ÷ b (NOT b ÷ a)

File Modes

ModeAction
"r"Read
"w"Write (overwrite)
"a"Append

MUST CLOSEFILE!

Exception Handling

TRY
// code that might fail
EXCEPT
// handle error gracefully
ENDTRY

Catches runtime errors only, not syntax errors.

Paradigm ID — Quick Check

Code has...Paradigm
CLASS, methodsOOP
facts, rules, ?-Declarative
MOV, registersLow-level
FOR, WHILE, ←Imperative