haskell笔记1
2018-01-31 16:11
225 查看
1 .function_name
functions can’t begin with uppercase letters2 . how to unload a module
type in :m:m
3 . name(definition)
When a function doesn’t take any parameters, we usually say it’s a definition (or a name). Because we can’t change what names (and functions) mean once we’ve defined them4 .list
1.list is homogenous(同质的)2.putting two lists together
//1:this method only takes two lists! //2:will walk through the whole two lists,if add two very //long lists together,it will cost a lot of time [1,2,3,4]++[2,3,4,5] >>[1,2,3,4,2,3,4,5] [1,2,3,4]++[5] >>[1,2,3,4,5] //[1,2,3,4]++5 is wrong
//1:can add a element at the beginning of a list(noted: //only a element) //2:only takes a element and a list 2:[1,2,3,4] >>[2,1,2,3,4] //[2]:[1,2,3] is wrong
3 .find a element by index
//find a element by index [1,2,3,4]!!3 >>4 "black"!!2 >>a
4.head tail init last用法
5 . make a list
[1,2..20] [2,4,6..20] [0.1,0.3,0.5..1] \\精度问题
6 .list comprihension
//集合说明方式
[x*2|x<-[1,2..10]] [x*2|x<-[1,2..10],x*2>12]
5 tuples
difference between list and tuple1.1 tuple is not homogenous(同质的)
1.2 tuple must be specified the number of values when it is created
some function used on pair
fst (1,2) >> 1 snd (2,3) >> 3 zip [1,2,3] [2,3,4] >> [(1,2),(2,3),(3,4)] //zip two lists into a pairs
6 note about difference between haskell and common language like c or python
/= means !=相关文章推荐
- haskell学习笔记_函数
- Haskell语言学习笔记(43)Parsec(2)
- Haskell语言学习笔记(50)Extra
- Haskell笔记(6)
- Haskell 笔记(四)函数系统
- Haskell语言学习笔记(7)IO 与随机数
- haskell笔记(1)
- Haskell语言学习笔记(20)IORef, STRef
- Haskell语言学习笔记(44)Lens(2)
- Haskell语言学习笔记(51)Comonad
- Haskell 笔记(三)类型系统
- haskell学习笔记(6)-Parameterised types与Recursive types
- Haskell学习笔记1
- Haskell语言学习笔记(21)Array
- Haskell语言学习笔记(11)Point-Free
- Haskell语言学习笔记(52)正则表达式
- haskell笔记(2)
- Haskell学习笔记 --- 基础语法篇二
- haskell学习笔记:List Comprehensions
- Haskell学习笔记 --- 函数式编程中的柯里化