Upcoming SlideShare
×

# Design Pattern In Functional Language

1,258
-1

Published on

3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total Views
1,258
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
0
0
Likes
3
Embeds 0
No embeds

No notes for slide

### Design Pattern In Functional Language

1. 1. Design Pattern In Functional Language<br />박상혁<br />-아꿈사:추가발표-<br />
2. 2. 목차<br />1. 함수형 언어<br />2.F#<br />3. Design Pattern<br />
3. 3. 함수형 언어<br />LISP<br />Common Lisp, Scheme, Clojure<br />ML<br />SML, nML, Ocaml, F#<br />Etc.<br />Haskell, Erlang<br />
4. 4. 함수형 언어<br />람다 대수(lambda calculus)<br />f(x) = x+10<br />(λx.x+10)<br />(λx.x+10) 32 = 32 + 10 = 42<br />(λop.λx.(op x x)) (+) 21 = (λx.((+) x x)) 21 = (+) 21 21 = 42<br />부수 효과(side-effect)<br />함수 실행이 외부에 끼치는 영향.<br />순수 함수형 언어는 부수효과가 전혀 없다.<br />
5. 5. 함수형 언어<br />재귀 (Recursion)<br />불변값(Immutable Value)<br />고차원 함수 (High-Order Function)<br />함수를 다루는 함수<br />타입 추론 (Type Inference)<br />ML류의 언어<br />
6. 6. F#History<br />F# 1.0.1<br />2005년, SDK For VS2003<br />OCaml을 .NET으로<br />F# 2.0<br />2010년, VS2010 First Class Language<br />.NET Language<br />
7. 7. F# Basic<br />F# Interactive<br />Interpreter<br />Interactive Development<br />F# Tutorial<br />VS2010 에서 Tutorial Project 생성<br /><demo><br />
8. 8. F# Syntax<br />let<br />함수나 값을 정의<br />let x = 42let z : string = nulllet F x y = x + ylet F (x,y) = x + y<br />
9. 9. F# Syntax<br />fun<br />무명함수(람다) 정의<br />let nums = [1; 2; 3;]let odds =List.filter (fun x -> x%2 = 1) numslet oddsSquare = List.map (fun x -> x * x) (List.filter (fun x-> x%2 = 1 ) nums)<br />
10. 10. F# Syntax<br />|><br />파이프 연산자.<br />let odds =nums |> List.filter (fun x -> x%2 = 1)let oddsSquare =nums |> List.filter (fun x -> x%2 = 1) |> List.map (fun x -> x*x)<br />별거 아닌거 같지만 상당히 가독성을 높여준다.<br />
11. 11. F# Syntax<br />Discriminated Union<br />type Shape = | Rect of Point * Point | Ellipse of Point * Point | Comp of Shape * Shape<br />
12. 12. F# Syntax<br />Pattern Match<br />let AreaOf shape = match shape with | Rect(pf, pt) -> rectArea(pf,pt) | Ellipse(pf,pt) -> ellipseArea(pf,pt) | Comp(Rect(p1,p2), Rect(p3,p4)) when isNested(p3,p4,p1,p2) -> rectArea(p1,p2) | Comp(s1,s2) -> let area1 = shapeArea(s1) let area2 = shapeArea(s2) area1 + area2 – (intersectArea(s1,s2))<br />
13. 13. Design Pattern<br />Strategy Pattern<br />Command Pattern<br />Composite Pattern<br />Decorate Pattern<br />
14. 14. Strategy Pattern<br />
15. 15. Composite Pattern<br />
16. 16. Command Pattern<br />
17. 17. Decorate Pattern<br />
18. 18. 참고자료<br />http://www.functional-programming.net/<br />Head First Design Patterns<br />http://oreilly.com/catalog/9780596007126<br />