That's a clever routine. It should be faster than mine since it only makes a single pass though the list. Thanks for all the suggestions from everyone that responded. Here is a link to some more info on the project I'm working on if anyone is interested:
<a href="http://ehaskell.blogspot.com/">http://ehaskell.blogspot.com/</a><br><br>-Eric<br><br><div><span class="gmail_quote">On 2/5/07, <b class="gmail_sendername">ihope</b> <<a href="mailto:ihope127@gmail.com">ihope127@gmail.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 2/4/07, Eric Olander <<a href="mailto:olandere@gmail.com">olandere@gmail.com
</a>> wrote:<br>> Hi,<br>> I'm still somewhat new to Haskell, so I'm wondering if there are better<br>> ways I could implement the following functions, especially shiftl:<br>><br>> >> moves the last element to the head of the list
<br>> shiftl :: [a] -> [a]<br>> shiftl [] = []<br>> shiftl x = [last x] ++ init x<br><br>Well, you could try this, though I'm actually sure it's any faster:<br><br>> shiftl (x1:x2:xs) = last:x1:init
<br>> where last:init = shiftl (x2:xs)<br>> shiftl [x] = [x]<br>> shiftl [] = error "shiftl: empty list"<br><br>Or, if you don't want to give an error on [], omit the last line and
<br>replace both of the [x] with xs.<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>