Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Haskell - A brief introduction
Search
MetaBroadcast
June 13, 2012
Programming
0
77
Haskell - A brief introduction
Talk given by Fred van den Driessche on 13-06-2012 at MetaBroadcast.
MetaBroadcast
June 13, 2012
Tweet
Share
More Decks by MetaBroadcast
See All by MetaBroadcast
PhotoGlut
metabroadcast
2
350
Machine learning: boldly going where Twitter's APIs don't
metabroadcast
0
120
monitoring: it gets better
metabroadcast
1
560
The ABCs of MetaBroadcast APIs
metabroadcast
0
160
APIs for app developers
metabroadcast
1
140
Polishing Varnish
metabroadcast
0
820
Atlas - 3.0 to 4.0
metabroadcast
0
240
Atlas - owl vs deer
metabroadcast
0
240
Storm - an overview
metabroadcast
0
120
Other Decks in Programming
See All in Programming
実践!難読化ガイド
mitchan
0
160
いつか使える ObjectSpace / Maybe useful ObjectSpace
euglena1215
2
130
Some more adventure of Happy Eyeballs
coe401_
2
180
Google Sign-inの移行から始めるCredential Manager活用
clockvoid
0
220
Debugging: All you need to know (for simultaneous interpreting)
jmatsu
2
760
サーバーレスで負荷試験!Step Functions + Lambdaを使ったk6の分散実行
shuntakahashi
6
1.5k
A New Era of Testing
mannodermaus
2
490
Rubyとクリエイティブコーディングの輪の広がり / The Growing Circle of Ruby and Creative Coding
chobishiba
1
270
o1モデルのプロンプトエンジニアリングって?
ktc_wada
0
180
Amebaチョイス立ち上げの裏側 ~依存システムとの闘い~
daichi_igarashi
0
230
【TID2024】模擬講義:プログラマと一緒にゲームをデザインしてみよう!
akatsukigames_tech
0
640
KSPの導入・移行を前向きに検討しよう!
shxun6934
PRO
0
220
Featured
See All Featured
Music & Morning Musume
bryan
46
6k
How to Think Like a Performance Engineer
csswizardry
16
960
Automating Front-end Workflow
addyosmani
1365
200k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
190
16k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
103
48k
Fashionably flexible responsive web design (full day workshop)
malarkey
401
65k
KATA
mclloyd
27
13k
For a Future-Friendly Web
brad_frost
174
9.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
36
1.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
89
16k
The Cult of Friendly URLs
andyhume
76
6k
Transcript
Haskell A Brief Introduction
Pure Functional Lists Lazy • • •
Built-in Types Numbers: 1, 1.234 Booleans: True, False Characters/Strings: 'a',
"asdf" Lists: [1,2,3] Tuples:("jim", 25) • • • • •
Functions double x = 2 * x > double 5
10
Control max x y = if x > y then
x else y max x y | x > y = x | otherwise y
Lists [] 1 : [2, 3] = [1, 2, 3]
[1, 2] ++ [3, 4] = [1, 2, 3, 4] head [1, 2, 3] = 1 tail [1, 2, 3] = [2, 3]g • • • • •
Pattern Matching dblAll [] = [] dblAll (x:xs)= double x
: dblAll xs
Higher-order functions > map double [1, 2, 3] [2, 4,
6] map f [] = [] map f (x:xs) = f x : map f xs
Function Types > :t double double :: Num a =>
a -> a > :t (*) (*) :: Num a => a -> a -> a > :t map map :: (a -> b) -> [a] -> [b]
Currying > :t (*) (*) :: Num a => a
-> a -> a > :t (2*) (2*) :: Num a => a -> a double = 2* dblAll = map (2*)
Data Types data Bool = True | False data Maybe
a = Just a | Nothing data Either a b = Left a | Right b data Tree a = Empty | Node a (Tree a) (Tree b ) • • • •
yesOrNo True = "yes" yesOrNo False = "no" traverse Empty
= [] traverse (Node v l r) = (traverse l) ++ v : traverse r
Laziness fib c n = c : fib n (c
+ n) > fib 0 1 [0, 1, 1, 2, 3, 5, 8, 13, 21 ... > take 5 (fib 0 1) [0, 1, 1, 2, 3]
Laziness > (fib 0 1) !! 900 54877108839480000051413673948383714443800