% $Id: Hailstone.oz,v 1.1 2007/10/29 19:52:10 leavens Exp leavens $ % AUTHOR: Gary T. Leavens declare % The following is really the T function from the 3x+1 problem % since it divides by 2 in both cases. fun {Hailstone N} if {IsOdd N} then (3*N+1) div 2 else N div 2 end end % Return a list of the iterates of N. fun {IterHailstone N} N | if N == 1 then nil else {IterHailstone {Hailstone N}} end end