我有一个字符串头结束列表和背部移动ELEM索引
我写的第一功能的列表,但它不工作
head_to_end :: [String] -> [String]
head_to_end x = t : h
where h = `head` x
t = `tail` x
我应该得到的东西这样
head_to_end ["1", "2", "3", "4", "5"] -> ["2", "3", "4", "5", "1"]
last_to_head ["1", "2", "3", "4", "5"] -> ["5", "1", "2", "3", "4"]
move_elem_1_to_4 :: Int -> Int -> [String] -> [String]
move_elem_1_to_4 ["a", "b", "c", "d", "e"] -> ["b", "c", "d", "a", "e"]
虽然此代码片段可能会解决问题,但[包括解释](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)确实有助于提高您的质量帖子。请记住,您将来会为读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性注释来挤占代码,这会降低代码和解释的可读性! – SmokeDispenser
@SmokeDispenser谢谢你指出。解释补充说。 – veidt