Using arbitrary LISP expressions with STACK in moodle

Re: Using arbitrary LISP expressions with STACK in moodle

by Leo Butler -
Number of replies: 0

Dirk,

Here is a sketch of my solution to your problem: write a function that generates a list of the digits base N of a number x and returns that list. E.g. if x=x_k*N^k + ... + x_1*N + x_0 with 0 <= x_i < N for each i, then

base(x,N) -> [x_k, ...., x_0]

This would let your grader check the student's answer in a number of ways which a simpler representation would not (e.g. are all the digits in the allowed range). And for base N>10, there is no problem, you can use a lookup table to symbolize the i-th digit.

The student input may involve more syntax, but it is easily explicable.

(I came across your interesting question while trying to find an answer to a problem I have, hence the very late reply).