lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> [...] I LOVE this book, I have a few notes on it and I want
> authors (and anyone who is interested) to hear my feedback. So here
> it is:

Many thanks for the feedback.


> [...] It had started with exercise 4.3 where I was really
> unsure what was the point of that weird go-to code,

Exercise 4.3 has nothing to do with gotos. Maybe you meant 4.6? (That
one is a little tough :)


> continued with
> 5.4 - although I program for some time, I was unable to wrote that
> recursive program using that description. From it I understand that
> the code should have looked something like:
> 
> function combinations(tbl, n, m)
>   if n < m then
>     return nil
>   else if m == 0 then
>     return {}
>   else
>     rsln = {}
>     rsln[1] = tbl[1]
>     combinations(rsln, n-1, m-1)
>     table.delete(tbl, 1)
>     combinations(rsln, n-1, m)
>     return rsln
>   end
> end

The general idea is correct, but the details are not. (First, you
should not return when you hit a base case without printing the solution.
Second, you cannot create a new table and restart from 1 at each
recursive call; you must keep filling the same table one element at
a time, so that when you hit the base case the table has a complete
combination. See the permutation example at Listing 9.2 for inspiration.)


>   But the shock comes with exercise 6.1. Either I'm missing
> point or it's pretty non-trivial algorithm. In my language we have
> two different "integrals": specific integral and non-specific integral.
> Specific integral is something that is called "integral" in English:
> area of the region in the xy-plane bounded by the graph f, x-axis and
> the vertical lines x = a and x = b. I can solve this kind of integral
> numerically (e. g. with Runge-Kutta methods), but you should have
> range where you are solving it and in your assignment there is
> nothing said about "range argument", [...]

I am very sorry; the text is not that clear. The idea is for the
function to return a definite integral *function* that, when given a and
b, return the integral in that region. (So, yes, you should use some
numerical method.) I will add some clarification in the errata.


> 6) I have never saw so much use of a word "seldom" in my life :-).

I seldom use that word ;) The book has 15 occurences of "seldom", or one
for every 25 pages, on average. Is that too much?

-- Roberto