NB. Definitions for Program Execution Time maximum =: monad def 'max_helper (rest y.) ; head y.' max_helper =: monad define ('ls' ; 'max') =. y. if. nullp ls do. max elseif. max < head ls do. max_helper (rest ls) ; head ls elseif. 1 do. max_helper (rest ls) ; max end. ) traced_maximum =: monad def 'traced_max_helper (rest y.) ; head y.' traced_max_helper =: monad define entering y. ('ls' ; 'max') =. y. if. nullp ls do. max elseif. max < head ls do. leaving traced_max_helper (rest ls) ; head ls elseif. 1 do. leaving traced_max_helper (rest ls) ; max end. ) sort_pass =: monad define NB. stop when we have a list of two items if. nullp rest rest y. do. if. (head y.) < head rest y. do. y. else. reverse y. end. else. one =. head y. two =. head rest y. if. one < two do. one append sort_pass rest y. else. two append sort_pass one append rest rest y. end. end. ) traced_sort_pass =: monad define NB. stop when we have a list of two items entering y. if. nullp rest rest y. do. if. (head y.) < head rest y. do. leaving y. else. leaving reverse y. end. else. one =. head y. two =. head rest y. if. one < two do. leaving one append traced_sort_pass rest y. else. leaving two append traced_sort_pass one append rest rest y. end. end. ) sort =: monad define NB. stop when we have a list of two items if. nullp rest rest y. do. sort_pass y. else. result =. sort_pass y. (sort drop_last result) append last result end. ) traced_sort =: monad define NB. stop when we have a list of two items entering y. if. nullp rest rest y. do. leaving sort_pass y. else. result =. sort_pass y. leaving (traced_sort drop_last result) append last result end. ) show_move =: monad def 'display (0 from y.) , '' -> '' , 1 from y.' move =: monad define ('n' ; 'src' ; 'dst' ; 'hlp') =. y. if. n = 1 do. show_move src , dst else. move (n - 1) ; src ; hlp ; dst show_move src , dst move (n - 1) ; hlp ; dst ; src end. ) display_tower_hanoi =: monad def '0$move y. ; ''a'' ; ''c'' ; ''b'''