haskell笔记1

1 .function_name

functions can’t begin with uppercase letters

2 . 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 them

4 .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用法
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

  1. difference between list and tuple
    1.1 tuple is not homogenous(同质的)
    1.2 tuple must be specified the number of values when it is created
  2. 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

  1. /= means !=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值