Dnia Thu, 29 Jul 2010 16:57:21 +0000, Adam Majewski napisa?(a):
> Hi ,
>
> I want to translate Lisp code to Maxima.
>
> I have Lisp function :
>
> (defun draw-apollonian-gasket (c1 c1 c2 steps)
> (if (> steps 0)
> (let ((c4 (draw-forth-circle c1 c1 c2 ))) ;
> (draw-apollonian-gasket c1 c1 c4 (- steps 1)) ; c5
> (draw-apollonian-gasket c1 c2 c4 (- steps 1)) ; c6
> (draw-apollonian-gasket c2 c1 c4 (- steps 1))))); c7=c6
>
>
> It gives 4 output values c4 and c5,c6 and c7 ( equal to c6)
>
> My Maxima version is :
>
> make_steps(ka,kb,kc,steps):=
> (
> [kd],
> if steps>0
> then (
> kd:make_k(ka,kb,ka),
> make_steps(ka,kb,kd,steps-1), /* ke */ make_steps
(kb,ka,kd,steps-1),
> /* kf */ make_steps(ka,ka,kd,steps-1)) /* kg*/
>
> );
>
>
> It gives 4 output values :
> kd, ke, kf, kg
> Here :
> ke value is good,
> kf value is bad,
> kg is not equal kf ( and its value is bad ).
>
>
> It seems that something is wrong with transition of values to called
> function.
> I think that this is because of different syntax of LIsp and MAxima (
> and of course my litle knowlage about it )
>
> Am I right ?
> How can I change it ?
>
> TIA
>
> Adam
Here is correct version ( thx to RJF ) :
make_steps(ka,kb,kc,steps):=
block
(
[kd],
if steps>0
then (
kd:make_k(ka,kb,ka),
make_steps(ka,kb,kd,steps-1), /* ke */
make_steps(kb,ka,kd,steps-1), /* kf */
make_steps(ka,ka,kd,steps-1))); /* kg*/
Adam