A declarative program is a collection of facts. An imperative program is a collection of commands (ordered, or structured, in some way).
A garbage collector finds memory that is not in use by a program and returns it to the pool of free memory.
Interpreters are more portable then compilers, and are often easier to write. Debugging tends to be easier with interpreters. Compilers produce much faster executable code, and can be chained (doing multiple translations). A compiled language can be implemented in itself. (The first Pascal compiler was written in Pascal.)
The lvalue is the variable itself, while the rvalue is the content of the variable.
In object-based programming, the fundamental concept is that of
an object. Objects represent the unit of encapsulation. In
object-oriented programming, the fundamental concept and unit
of encapsulation is a class.
In object-based programming, each object is build in a custom
way. In object-oriented programming, objects are built according
to the plans of a class, and many identical objects can be stamped
out from the same mold.
It does constructive existence proofs.
The axioms must be Horn clauses.
A lexeme is a sequence of characters that stands for a token. A token is a concept of the language. For example, C++ has a token called if. Its lexeme is the string "if".
For :: a good representation is the linked representation. For indexing, sequential representation is better.
double(x) = 2*x.
Answer: lfold(0,+) (map double (0 upto n/2))
(I have assumed that n is even.)
Using a for a type variable, the type is f: ([a],a) -> [a].
Using a and b for a type variables, the type is g: (a -> b) -> [a] -> b
g x is a function.
In a strongly typed language, all type checking is done at compile time. In an untyped language, all type checking is done at run time. In a weakly typed language, some type checking is done at compile time and some at run time.
(define (f x) (if (null? x) x (cons (car x) (cons (car x) (f (cdr x)))) ) )
(a a b b c c)
It examines tags of objects and finds functions for those objects, from the tags and the names of the functions.
A virtual function is a function that logically belongs at a level in the class hierarchy above the level where it can be defined.
A private variable is available only in one class. A protected variable is available in a class and all of its subclasses.
They are inherited by position. They are always in the same place in the representation of an object, regardless of the actuall class of the object.
An interface is like an abstract class that only contains virtual functions. (It has no data or nonvirtual functions.) A class can implement several interfaces but can only extend one class.
It means the the variable or method is associated with the class itself, not with the objects that belong to the class.
It looks at the static link in its activation.
A function closure is a combination of a function (given by its executable code) and an environment. The environment is the same thing as a static link in an activation.
It succeeds. The result is g(f(X,a),h(W)), with bindings Z = f(X,a) and Y = h(W) being done.
<S> -> a<S> a <S> -> b<S> b <S> -> cShow that string abbcbba can be derived from <S> by showing a parse tree for it.
S
/|\
/ | \
a S a
/|\
/ | \
b S b
/|\
/ | \
b S b
|
|
c
It removes control frames from the control stack back to a marker frame. The effect is to prune branches from the backtrack search tree.
twist([]) = [] twist(a::b::c) = b::a::twist(c)(Twist is not defined for every list.) Show an evaluation by substitution of expression twist [2,3,4,5,6,7].
twist [2,3,4,5,6,7] = 3::2::twist[4,5,6,7]
= 3::2::5::4::twist[6,7]
= 3::2::5::4::7::6::twist[]
= 3::2::5::4::7::6::[]
= [3,2,5,4,7,6]
lefts ([]) = []
lefts (h::t) = left(h) :: lefts(t)
append([], X, X). append([H|T], X, [H|Y]) :- append(T, X, Y).(Recall that [H|T] is the list whose head is H and whose tail is T, and that :- is the reverse implication, <=.) Show a proof tree, with variable bindings on the branches, for goal append(X, [3,4], [1,2,3,4]). Show all branches of the computation, including failed branches. Be sure to copy variables where copying is required.
I will skip writing bindings that have no use in the end.
append(X, [3,4], [1,2,3,4])
|
| X = [H1|T1], H1 = 1
|
append(T1, [3,4], [2,3,4])
|
| T1 = [H2|T2], H2 = 2
|
append(T2, [3,4], [3,4])
|
| T2 = []
|
success
The result is X = [H1 | [H2 | []]]. If this is written using the
:: operator instead of the bar notation, it is H1::H2::[], or
[H1, H2]. So X = [1,2].