名称“xs”在哪里?模式匹配来自哪里? [英] Where does the name "xs" for pattern matching come from?
本文介绍了名称“xs”在哪里?模式匹配来自哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
变量名称x和xs的历史记录是什么?
模式匹配中的规范名称xs来自哪里?
例如。在
reverse'[] = []
reverse'[x] = [x]
reverse '(x:xs)= reverse'xs ++ [x]
它应该是复数x?
解决方案
这是我一直阅读的方式,你有单数和复数,所以 x:xs
或 y:ys
等。
它本身并没有任何意义,它只是一个约定。
IIRC它也在学习你一个Haskell 。
编辑
我的错误 - 实际上是在真实世界Haskell 的类型和函数一章。
pngalt =在这里输入图片描述>Possible Duplicate:
What is the history of the variable names x and xs?
Where does the canonical name "xs" in pattern matching come from?
e.g. in
reverse' [] = []
reverse' [x] = [x]
reverse' (x:xs) = reverse' xs ++ [x]
Is it supposed to be the plural of "x" ?
解决方案
That's the way I've always read it, you have the singular and the plural, So x:xs
or y:ys
etc.
It doesn't actually have any meaning by itself, it's just a convention.
IIRC it's also mentioned in Learn You a Haskell.
Edited
My mistake - it's actually in Real World Haskell in the chapter on types and functions.
这篇关于名称“xs”在哪里?模式匹配来自哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文