News for hackers. Stuff that matters.
Re:Programming Without Variables by secretguy on Friday September 13, 2013 @05:43AM (#6379431)
Or perhaps like this if you do not want to use `reverse` and want it to be tail recursive:

    collatz :: Int -> [Int]
    collatz x = go id x []
      where
        go :: ([Int] -> [Int]) -> Int -> [Int] -> [Int]
        go f 1 = f . (1:) 
        go f n = 
          if even n
            then go (f . (n:)) (n `div` 2)
            else go (f . (n:)) (3 * n + 1)
Re:Programming Without Variables by masklinn on Friday September 13, 2013 @05:58AM (#6379458)
Why would you want to not use reverse? (tail-recursion is orthogonal, and I understand not really useful in haskell unless you force strict evaluation though I may be wrong)
Re:Programming Without Variables by zeckalpha on Friday September 13, 2013 @08:49AM (#6380084)
It increases the constant time, as reverse is O(n).