Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haskell要是改成这样就好了 by iwon #136

Open
freizl opened this issue Apr 30, 2018 · 2 comments
Open

Haskell要是改成这样就好了 by iwon #136

freizl opened this issue Apr 30, 2018 · 2 comments
Labels

Comments

@freizl
Copy link
Member

@freizl freizl commented Apr 30, 2018

1.定义函数时的“=”前加个冒号":",方便区分参数和函数体。
如:
sum : : Int -> Int -> Int ->Int
sum a b c = a+b+c (好像是c=a+b+c)
改为:
sum : : Int -> Int -> Int ->Int
sum a b c := a+b+c
":" 表示函数参数结束,后面跟等号表示函数体开始

2.[2n | n<-[2,4,7],n>3] 改为:[ n<-[2,4,7],n>3 | 2n ] 或 [ [2,4,7]->n,n>3 | 2*n ] ,"|" 左边表示可输入的元素,右边表示输出
如:
addpairs : : [(Int, Int)] -> [Int]
addpairs pairList :=[ pairList->(m,n) , m<n | m+n ]

@freizl freizl added the migration label Apr 30, 2018
@GordonGgx
Copy link

@GordonGgx GordonGgx commented Jul 3, 2019

多此一举

@xiaolzha
Copy link

@xiaolzha xiaolzha commented Jul 3, 2019

第一个没必要。加完以后 := 和= 是完全等价的,而且现在并没有会出现=歧义的情况。
第二个现在的写法和数学定义是一样的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants