Task

Solve the   Towers of Hanoi   problem with recursion.




*       # Note: count is global
 
        define('hanoi(n,src,trg,tmp)') :(hanoi_end)
hanoi   hanoi = eq(n,0) 1 :s(return)
        hanoi(n - 1, src, tmp, trg)
        count  = count + 1
        output = count ': Move disc from ' src ' to ' trg
        hanoi(n - 1, tmp, trg, src) :(return)
hanoi_end
 
*       # Test with 4 discs
        hanoi(4,'A','C','B')
end