## Extra Lab Questions for COMP9814 Extended Artificial Intelligence

- Write a Prolog procedure
`vector_access(Vector, Position, Value)`

to access the `N`

^{th} item in a `Vector`

and return
it as `Value`

. Assume that the vector is represented as a list.
What does your code do if `N`

the length of the
`Vector`

? What *should* it do?

- Write a Prolog procedure
`matrix_access(Matrix, Row, Column, Value)`

to access the `M,N`

^{th} item in a `Matrix`

and return
it as `Value`

. Assume that the matrix is represented as a list of
lists.
- Write a Prolog procedure
`vector_dot_product(Vector1, Vector2, Product)`

to form the inner or dot product of `Vector1`

and `Vector2`

and return the result as `Product`

. Assume that both vectors
are represented as lists of numbers.
What does your code do if the two vectors are of different lengths?
What *should* it do in this case?

- Write a Prolog procedure
`matrix_transpose(Matrix, Transpose)`

to transpose a `Matrix`

, returning a copy of the transposed matrix
as `Transpose`

. Again assume list of lists representation for the
`Matrix`

.
- What happens if you apply
`atom_chars`

to a list of
digit characters like `['1', '7, '2']`

? Can you add 1 to the
result, using `is`

?

Now try the same experiment, but using `number_chars`

in place
of `atom_chars`

.

Finally, look up `number_chars`

using ?- help(number_chars).
in SWI Prolog.

Solutions are/will be here when available.

Bill Wilson's contact info

UNSW's CRICOS Provider No. is 00098G

Last updated: