[Haskell-cafe] tail recursion

2009-04-07 Thread Daryoush Mehrtash
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 "must have at least one element" mkDList xs = let (first,

[Haskell-cafe] tail recursion ?

2007-06-11 Thread H .
Hello @ all, Sometimes one has an imperative algorithm, and wants to write a program in Haskell which do has the same effect... So the question is - how a construct as the following can efficiently be written? -- Pseudo code: n[1..1] = false for (1..1) |i| for (i,2*i..1) |j

Re: [Haskell-cafe] tail recursion

2009-04-07 Thread wren ng thornton
Daryoush Mehrtash wrote: 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 "must have at least one element" mkDList xs = let (first,last) = go last xs first in first

[Haskell-cafe] Tail Recursion within the IO Monad

2007-05-16 Thread Rob Hoelz
Hello everyone, You may have seen my message about how I'm writing a binding to a C library. This is another question related to that. So, let's say I have a linked list implemented in C. Here's what its definition looks like: struct __linked_list { void *data; struct __linked_list *ne

Re: [Haskell-cafe] Tail Recursion within the IO Monad

2007-05-16 Thread Brandon S. Allbery KF8NH
On May 16, 2007, at 12:23 , Rob Hoelz wrote: And as long as I'm asking, is there some kind of monadic function composition operator? I'd like to clean up the above with something like peekCString . peek . linked_list_getdata... (=<<)? -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell

Re: [Haskell-cafe] Tail Recursion within the IO Monad

2007-05-16 Thread Rob Hoelz
"Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> wrote: > > On May 16, 2007, at 12:23 , Rob Hoelz wrote: > > > And as long as I'm asking, is there some kind of monadic function > > composition operator? I'd like to clean up the above with something > > like peekCString . peek . linked_list_getdat

Re: [Haskell-cafe] Tail Recursion within the IO Monad

2007-05-16 Thread Jules Bean
Rob Hoelz wrote: item <- linked_list_getdata listPtr next <- linked_list_next listPtr cStr <- peek item hStr <- peekCString cStr t <- linkedListToStringList next return (hStr : t) item <- linked_list_getdata listPtr next <-