SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Design Pattern In Functional Language 박상혁 -아꿈사:추가발표-
목차 1. 함수형 언어 2.F# 3. Design Pattern
함수형 언어 LISP Common Lisp, Scheme, Clojure ML SML, 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#History F# 1.0.1 2005년, SDK For VS2003 OCaml을 .NET으로 F# 2.0 2010년, VS2010 First Class Language .NET Language
F# Basic F# Interactive Interpreter Interactive Development F# Tutorial VS2010 에서 Tutorial Project 생성 <demo>
F# Syntax let 함수나 값을 정의 let x = 42let z : string = nulllet F x y = x + ylet F (x,y) = x + y
F# Syntax fun 무명함수(람다) 정의 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# Syntax Discriminated Union type Shape =    | Rect of Point * Point    | Ellipse of Point * Point    | Comp of Shape * Shape
F# Syntax Pattern Match 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))
Design Pattern Strategy Pattern Command Pattern Composite Pattern Decorate Pattern
Strategy Pattern
Composite Pattern
Command Pattern
Decorate Pattern
참고자료 http://www.functional-programming.net/ Head First Design Patterns http://oreilly.com/catalog/9780596007126

Weitere ähnliche Inhalte

Was ist angesagt?

알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)HYUNJEONG KIM
 
말의여행
말의여행말의여행
말의여행mil23
 
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...Seok-joon Yun
 
Project#2말의여행 Hwp
Project#2말의여행 HwpProject#2말의여행 Hwp
Project#2말의여행 HwpKimjeongmoo
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 명신 김
 
[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기
[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기
[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기종빈 오
 
2.1 부동소수점 비법들
2.1 부동소수점 비법들2.1 부동소수점 비법들
2.1 부동소수점 비법들준섭 김
 

Was ist angesagt? (9)

알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
알고리즘 연합캠프 세미나 1-C (알고리즘 설계와 모델링 및 수학)
 
말의여행
말의여행말의여행
말의여행
 
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
 
자료구조02
자료구조02자료구조02
자료구조02
 
Project#2말의여행 Hwp
Project#2말의여행 HwpProject#2말의여행 Hwp
Project#2말의여행 Hwp
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14
 
[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기
[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기
[SICP] 4.4 Logic Programming : 논리로 프로그램 짜기
 
2.1 부동소수점 비법들
2.1 부동소수점 비법들2.1 부동소수점 비법들
2.1 부동소수점 비법들
 
HI-ARC PS 101
HI-ARC PS 101HI-ARC PS 101
HI-ARC PS 101
 

Andere mochten auch

Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologSH Park
 
xunittestpatternchapter15
xunittestpatternchapter15xunittestpatternchapter15
xunittestpatternchapter15SH Park
 
5장. 그래프와 트리 (3,4)
5장. 그래프와 트리 (3,4)5장. 그래프와 트리 (3,4)
5장. 그래프와 트리 (3,4)SH Park
 
PrimesIsInP
PrimesIsInPPrimesIsInP
PrimesIsInPSH Park
 
4장 스포츠 시뮬레이션 - 단순 축구
4장 스포츠 시뮬레이션 - 단순 축구4장 스포츠 시뮬레이션 - 단순 축구
4장 스포츠 시뮬레이션 - 단순 축구SH Park
 
도메인 주도 설계 - 16 대규모 구조
도메인 주도 설계 - 16 대규모 구조도메인 주도 설계 - 16 대규모 구조
도메인 주도 설계 - 16 대규모 구조SH Park
 
Apprenticeship patterns chapter4
Apprenticeship patterns chapter4Apprenticeship patterns chapter4
Apprenticeship patterns chapter4SH Park
 
프로그래머의 길,멘토에게 묻다 2장
프로그래머의 길,멘토에게 묻다 2장프로그래머의 길,멘토에게 묻다 2장
프로그래머의 길,멘토에게 묻다 2장hyun soomyung
 
Nodejs_chapter9
Nodejs_chapter9Nodejs_chapter9
Nodejs_chapter9SH Park
 

Andere mochten auch (9)

Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
xunittestpatternchapter15
xunittestpatternchapter15xunittestpatternchapter15
xunittestpatternchapter15
 
5장. 그래프와 트리 (3,4)
5장. 그래프와 트리 (3,4)5장. 그래프와 트리 (3,4)
5장. 그래프와 트리 (3,4)
 
PrimesIsInP
PrimesIsInPPrimesIsInP
PrimesIsInP
 
4장 스포츠 시뮬레이션 - 단순 축구
4장 스포츠 시뮬레이션 - 단순 축구4장 스포츠 시뮬레이션 - 단순 축구
4장 스포츠 시뮬레이션 - 단순 축구
 
도메인 주도 설계 - 16 대규모 구조
도메인 주도 설계 - 16 대규모 구조도메인 주도 설계 - 16 대규모 구조
도메인 주도 설계 - 16 대규모 구조
 
Apprenticeship patterns chapter4
Apprenticeship patterns chapter4Apprenticeship patterns chapter4
Apprenticeship patterns chapter4
 
프로그래머의 길,멘토에게 묻다 2장
프로그래머의 길,멘토에게 묻다 2장프로그래머의 길,멘토에게 묻다 2장
프로그래머의 길,멘토에게 묻다 2장
 
Nodejs_chapter9
Nodejs_chapter9Nodejs_chapter9
Nodejs_chapter9
 

Ähnlich wie Design Pattern In Functional Language

스칼라와 스파크 영혼의 듀오
스칼라와 스파크 영혼의 듀오스칼라와 스파크 영혼의 듀오
스칼라와 스파크 영혼의 듀오Taeoh Kim
 
Macro & compilation
Macro & compilationMacro & compilation
Macro & compilationIkhoon Eom
 
R 기초 : R Basics
R 기초 : R BasicsR 기초 : R Basics
R 기초 : R BasicsYoonwhan Lee
 
TABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracle
TABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracleTABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracle
TABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracle엑셈
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조영기 김
 
R 프로그래밍 기본 문법
R 프로그래밍 기본 문법R 프로그래밍 기본 문법
R 프로그래밍 기본 문법Terry Cho
 
Pure Function and Honest Design
Pure Function and Honest DesignPure Function and Honest Design
Pure Function and Honest DesignHyungho Ko
 
Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질aceigy6322
 

Ähnlich wie Design Pattern In Functional Language (15)

Go
GoGo
Go
 
함수적 사고 2장
함수적 사고 2장함수적 사고 2장
함수적 사고 2장
 
스칼라와 스파크 영혼의 듀오
스칼라와 스파크 영혼의 듀오스칼라와 스파크 영혼의 듀오
스칼라와 스파크 영혼의 듀오
 
Macro & compilation
Macro & compilationMacro & compilation
Macro & compilation
 
R 기초 : R Basics
R 기초 : R BasicsR 기초 : R Basics
R 기초 : R Basics
 
Valentine
ValentineValentine
Valentine
 
TABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracle
TABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracleTABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracle
TABLE ACCESS 패턴을 이용한 SQL 튜닝_Wh oracle
 
Erlang
ErlangErlang
Erlang
 
Clojure Monad
Clojure MonadClojure Monad
Clojure Monad
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조
 
Java8 람다
Java8 람다Java8 람다
Java8 람다
 
7장매크로
7장매크로7장매크로
7장매크로
 
R 프로그래밍 기본 문법
R 프로그래밍 기본 문법R 프로그래밍 기본 문법
R 프로그래밍 기본 문법
 
Pure Function and Honest Design
Pure Function and Honest DesignPure Function and Honest Design
Pure Function and Honest Design
 
Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질
 

Design Pattern In Functional Language

  • 1. Design Pattern In Functional Language 박상혁 -아꿈사:추가발표-
  • 2. 목차 1. 함수형 언어 2.F# 3. Design Pattern
  • 3. 함수형 언어 LISP Common Lisp, Scheme, Clojure ML SML, nML, Ocaml, F# Etc. Haskell, Erlang
  • 4. 함수형 언어 람다 대수(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) 함수 실행이 외부에 끼치는 영향. 순수 함수형 언어는 부수효과가 전혀 없다.
  • 5. 함수형 언어 재귀 (Recursion) 불변값(Immutable Value) 고차원 함수 (High-Order Function) 함수를 다루는 함수 타입 추론 (Type Inference) ML류의 언어
  • 6. F#History F# 1.0.1 2005년, SDK For VS2003 OCaml을 .NET으로 F# 2.0 2010년, VS2010 First Class Language .NET Language
  • 7. F# Basic F# Interactive Interpreter Interactive Development F# Tutorial VS2010 에서 Tutorial Project 생성 <demo>
  • 8. F# Syntax let 함수나 값을 정의 let x = 42let z : string = nulllet F x y = x + ylet F (x,y) = x + y
  • 9. F# Syntax fun 무명함수(람다) 정의 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)
  • 10. 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) 별거 아닌거 같지만 상당히 가독성을 높여준다.
  • 11. F# Syntax Discriminated Union type Shape = | Rect of Point * Point | Ellipse of Point * Point | Comp of Shape * Shape
  • 12. F# Syntax Pattern Match 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))
  • 13. Design Pattern Strategy Pattern Command Pattern Composite Pattern Decorate Pattern
  • 18. 참고자료 http://www.functional-programming.net/ Head First Design Patterns http://oreilly.com/catalog/9780596007126