Example in Operators manual section



----Jorge Barros de Abreu wrote: -----

>I'm copy the folowing example from maxima manual:
>************************************
>(%i1) unitfrac(r) := block([uf : [], q],
>     if not(ratnump(r)) then error("The input to
>'unitfrac' must be a rational
>number"),
>     while r # 0 do (
>         uf : cons(q : 1/ceiling(1/r), uf),
>         r : r - q),
>     reverse(uf));
>(%i2) unitfrac (9/10);
>**************************************
>
>Maxima accept (%i1) but when i type (%i2) the
>maxima interactive prompt do not
>return.

Does your Maxima have the ceiling function? What
happens when you enter ceiling(28/9)? I don't know
when ceiling was added, but it was in the past few years.

The 'unitfrac' function seems to work with my 5.9.3.

(%i50) unitfrac(r) := block([uf : [], q],
    if not(ratnump(r)) then error("The input to 'unitfrac' must be a
    rational
number"),
    while r # 0 do (
        uf : cons(q : 1/ceiling(1/r), uf),
        r : r - q),
    reverse(uf))$
(%i51) unitfrac (9/10);
(%o51) [1/2,1/3,1/15]
(%i52) apply("+",%);
(%o52) 9/10

Barton