软糖

Candy


  • Home

  • Archives

  • Tags

  • Search
close
软糖

Haskell 7 Create new Types and Typeclass

Posted on 2017-11-13 |

Taking Notes from http://learnyouahaskell.com

Algebraic Data Types

Option 1: data

data ValueName = Value Constructor

1
2
data Bool = False | True
data Shape = Circle Float Float Float | Rectangle Float Float Float Float

Shape is type, but Circle is not.
[]、False 或 5,它们都是不包含参数的值构造子

Read more »
软糖

Haskell 6 Module

Posted on 2017-10-28 |

Taking Notes from http://learnyouahaskell.com

Modules

1
2
3
4
import Data.List
numUniques :: (Eq a) => [a] -> Int
numUniques = length . nub
Read more »
软糖

cloud

Posted on 2017-10-26 |

2017年10月26日

阴天了,女儿给我解释道:
云彩的小宝宝还不来
云彩的小宝宝是小水滴
云彩的上面是医院吗?

软糖

Haskell 5 HOF

Posted on 2017-10-19 |

Taking Notes from http://learnyouahaskell.com

Curried functions

1
2
3
4
5
compareWithHundred :: (Num a, Ord a) => a -> Ordering
compareWithHundred = compare 100
divideByTen :: (Floating a) => a -> a
divideByTen = (/10)
Read more »
软糖

Haskell 4 Recursive

Posted on 2017-10-19 |

Taking Notes from http://learnyouahaskell.com

Recursive

Read more »
软糖

wishes

Posted on 2017-10-19 |

2017年7月15日

女儿对着冰激凌许愿到:

天天吃爆米花不生病
吃到好多美食

软糖

Haskell 3 Function

Posted on 2017-10-17 |

Taking Notes from http://learnyouahaskell.com

Pattern matching

1
2
3
4
5
6
7
8
9
10
lucky :: (Integral a) => a -> String
lucky 7 = "LUCKY NUMBER SEVEN!"
lucky x = "Sorry, you're out of luck!"
factorial :: (Integral a) => a -> a
factorial 0 = 1
factorial n = n * factorial (n - 1)
addVectors :: (Num a) => (a, a) -> (b, b) -> (a, a)
addVectors (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)
Read more »
软糖

Haskell 2 Type and Typeclass

Posted on 2017-10-16 |

Taking Notes from http://learnyouahaskell.com

Type

1
2
3
4
ghci> :t 'a'
'a' :: Char
ghci> :t (True, 'a')
(True, 'a') :: (Bool, Char)
Read more »
软糖

Haskell 1 Basic and List

Posted on 2017-10-15 |

Taking Notes from http://learnyouahaskell.com

Function

  • infix (sanwich) : + - * /
  • prefix
1
2
doubleMe x = x + x
doubleUs x y = doubleMe x + doubleMe y
Read more »
软糖

save money

Posted on 2017-10-15 |

2017年09月15日

女儿睡前洗漱,自己玩出新的花样。
她用牙线当磨具,用洗手液当泡泡水,自己玩的不亦乐乎。
妈妈正巧走过来,开心的夸赞一番,女儿聪明啊,女儿有创造力啊
。
女儿却反问一句:
”妈妈你为什么这么开心,是应为以后不用买泡泡水,为你省钱了吗?“

1…3456
Steven Zhang

Steven Zhang

Java, Haskell and Architecture

57 posts
23 tags
GitHub
© 2016 - 2020 Steven Zhang
Powered by Hexo
Theme - NexT.Mist