最简单的答案是头部功能.
不幸的是,如果列表为空,这将产生运行时错误,所以最好像这样模式匹配:
case [2] of
x:_ -> do something with x
_ -> deal with the fact that the list is empty
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
170 次 |
| 最近记录: |