next up previous contents index
Next: A pretty rosette Up: Program examples Previous: And if you want   Contents   Index

A good example of using lists (with thanks to Olivier SC)

I hope you will appreciate this wonderful program:

to reversew :w
if empty? :w [output "]
output word last :w reversew bl :w
end

to palindrome :w
if equal? :w reversew :w [output "true] [output "false]
end

to palin :n
if palindrome :n [print :n stop] 
print se se se se :n "more reversew :n "equal sum :n reversew :n 
palin :n + reversew :n 
end

palin 78
78 more 87 equal 165
165 more 561 equal 726
726 more 627 equal 1353
1353 more 3531 equal 4884
4884



Loïc 2008-06-08