[Haskell-cafe] Idiomatically using lists
kevin birch
kbirch at pobox.com
Mon Jun 4 09:54:41 EDT 2007
Hello all,
I have an implementation question that I hope someone can help out
with. Say I have a fixed-size list: [1, 2, 3, 4, 5] that I want to
treat as circular in a function in order to rotate one of the
elements n positions. So rotating the second element 2 positions
would result in: [1, 3, 4, 2, 5], or rotating the fourth element 2
positions would result in: [1, 2, 4, 3, 5]. There are two cases: if
the element can be moved w/o rotating and where the element must be
inserted into the list at the front. Is there an idomatic way to
handle both of these cases in a function?
Thanks,
kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070604/843055c5/attachment.htm
More information about the Haskell-Cafe
mailing list