Is the call to "go" in the following code considered as tail recursion?

data DList a = DLNode (DList a) a (DList a)

mkDList :: [a] -> DList a

mkDList [] = error
<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:error>
"must have at least one element"
mkDList xs = let (first,last
<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last>)
= go last 
<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last>
xs first
             in  first

  where go :: DList a -> [a] -> DList a -> (DList a, DList a)
        go prev []     next = (next,prev)
        go prev (x:xs) next = let this        = DLNode prev x rest
                                  (rest,last
<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last>)
= *go this xs next*
                              in  (this,last
<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last>)


Daryoush
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to