Ad

write one compare function.

  • first compare with string's length
  • when string have same length, then compare string with lex order.
module CmpStr where

import Data.Function
import Data.Monoid

cmpStr :: String -> String -> Ordering
cmpStr = (compare `on` length) `mappend` compare

Haskell is lazy, so we could get infinite sequence naturally.

like this.

module InfiniteSeq where

import Data.List

ones = repeat 1
nats = [0..]

merge = concat . transpose
merge2 x y = merge [x, y]

ints = 0: merge2 [1..] [(-1),(-2)..]