Haskell99题答案
来源:互联网 发布:三毛 知乎 编辑:程序博客网 时间:2024/05/08 16:24
1 Problem 1
(*) Find the last element of a list.
(Note that the Lisp transcription of this problem is incorrect.)
Example in Haskell
Prelude> myLast [1,2,3,4]4Prelude> myLast ['x','y','z']'z'
run::[a]->arun [x]=xrun (_:xs) = run xs
run = foldl (const id)
对于上述的代码,有如下的解释
const id True 2= (const id True) 2= id 2= 2
如果要保留第一个,可以用如下的代码
foldl1 const [1,2,3,4]
0 0
- Haskell99题答案
- 数据库实验题答案
- 测试题基本答案
- 爱因斯坦题的答案~~
- 心理测试题答案
- 笔试题四+答案
- 腾讯笔试题答案
- 测试题答案
- p56 。 E4题答案
- 测试题答案
- 编程题答案
- 笔试题及答案
- 算法题--答案仅供参考
- 课后题答案
- JAVA编程题 答案
- Spring题和答案
- 逻辑推理题及答案
- java 50题答案
- 学jquery(二)大话jquery选择器
- Integer to Roman
- 学jquery(三)jquery动态创建元素和常用函数示例
- switch case
- 用 SQLite 和 FMDB 替代 Core Data
- Haskell99题答案
- 基于贪心算法求解TSP问题(JAVA)
- 学jquery(四)JQuery框架操作元素的属性与样式
- Apache Mina 学习笔记(2) - 基础
- 学jquery(五)jquery中的ajax详解
- eclipse下svn创建分支,合并,切换使用
- Roman to Integer
- Memory Management
- 学jquery(六)jquery中事件详解