Design Pattern In Functional Language박상혁-아꿈사:추가발표-
목차1. 함수형 언어2.F#3. Design Pattern
함수형 언어LISPCommon Lisp, Scheme, ClojureMLSML, nML, Ocaml, F#Etc.Haskell, Erlang
함수형 언어람다 대수(lambda calculus)f(x) = x+10(λx.x+10)(λx.x+10) 32 = 32 + 10 = 42(λop.λx.(op x x)) (+) 21 = (λx.((+) x x)) 21 = (+) 21 21 = 42부수 효과(side-effect)함수 실행이 외부에 끼치는 영향.순수 함수형 언어는 부수효과가 전혀 없다.
함수형 언어재귀 (Recursion)불변값(Immutable Value)고차원 함수 (High-Order Function)함수를 다루는 함수타입 추론 (Type Inference)ML류의 언어
F#HistoryF# 1.0.12005년, SDK For VS2003OCaml을 .NET으로F# 2.02010년, VS2010 First Class Language.NET Language
F# BasicF# InteractiveInterpreterInteractive DevelopmentF# TutorialVS2010 에서 Tutorial Project 생성<demo>
F# Syntaxlet함수나 값을 정의let x = 42let z : string = nulllet F x y = x + ylet F (x,y) = x + y
F# Syntaxfun무명함수(람다) 정의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)
F# Syntax|>파이프 연산자.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)별거 아닌거 같지만 상당히 가독성을 높여준다.
F# SyntaxDiscriminated Uniontype Shape =    | Rect of Point * Point    | Ellipse of Point * Point    | Comp of Shape * Shape
F# SyntaxPattern Matchlet 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))
Design PatternStrategy PatternCommand PatternComposite PatternDecorate Pattern
Strategy Pattern
Composite Pattern
Command Pattern
Decorate Pattern
참고자료http://www.functional-programming.net/Head First Design Patternshttp://oreilly.com/catalog/9780596007126

Design Pattern In Functional Language