SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Thinking in F#
Mike Clement
@mdclement
mike@softwareontheside.com
http://blog.softwareontheside.com
XP Simple Design
•Passes all tests
•Clear, expressive, consistent
•No duplication
•Minimal
FizzBuzz
• If multiple of 3, get “Fizz”
• If multiple of 5, get “Buzz”
• If not, return input int as string
• Rules are in order
FizzBuzz Code
Currying/Partial function application
let Multiples divisor result x s = if x % divisor =
0 then s + result else s
let Fizzy = Multiples 3 "Fizz"
val Multiples : divisor:int -> result:string ->
x:int -> s:string -> string
val Fizzy : (int -> string -> string)
let Fizzy x s = if x % 3 = 0 then s + "Fizz" else s
Bowling Game Kata
The game consists of 10 frames as shown above. In each frame the player has two
opportunities to knock down 10 pins. The score for the frame is the total number of pins
knocked down, plus bonuses for strikes and spares.
A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is
the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the
total number knocked down) plus a bonus of 5 (the number of pins knocked down on the
next roll.)
A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame
is the value of the next two balls rolled.
In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to
complete the frame. However no more than three balls can be rolled in tenth frame.
Bowling Game – The OO Way
Bowling Game
How do we get more functional?
Lists
[1, 2, 3, 4]
Head
Tail
Lists
[1, 2, 3, 4].Head = 1
[1, 2, 3, 4].Tail = [2, 3, 4]
[1, 2, 3, 4].Tail.Tail = [3, 4]
F# Resources
• http://en.wikibooks.org/wiki/F_Sharp_Programming
• F# for C# Developers by Tao Liu
• http://www.tryfsharp.org/
• https://github.com/ChrisMarinos/FSharpKoans
Mike Clement
• @mdclement
• mike@softwareontheside.com
• http://blog.softwareontheside.com
• https://github.com/mdclement
• http://agilecodegames.com
• Utah Software Craftsmanship
• http://utahsc.org
• @utahsc
• We meet the first Wednesday at SLCC

Weitere ähnliche Inhalte

Was ist angesagt?

Prof. Ledbetter's play-by-play notes
Prof. Ledbetter's play-by-play notesProf. Ledbetter's play-by-play notes
Prof. Ledbetter's play-by-play notesWelch Suggs
 
Variations Of Basketball For Family Fun
Variations Of Basketball For Family FunVariations Of Basketball For Family Fun
Variations Of Basketball For Family FunAce Surfaces, Inc
 
AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmKiran Shahi
 
Ig1 task 2 analysis work sheet 04
Ig1 task 2 analysis work sheet 04Ig1 task 2 analysis work sheet 04
Ig1 task 2 analysis work sheet 04BatmanGrunt
 

Was ist angesagt? (14)

3. research
3. research3. research
3. research
 
2006 Roughness
2006 Roughness2006 Roughness
2006 Roughness
 
Mathematics in sports
Mathematics in sportsMathematics in sports
Mathematics in sports
 
Basic things about tennis and basketball
Basic things about tennis and basketballBasic things about tennis and basketball
Basic things about tennis and basketball
 
Prof. Ledbetter's play-by-play notes
Prof. Ledbetter's play-by-play notesProf. Ledbetter's play-by-play notes
Prof. Ledbetter's play-by-play notes
 
Variations Of Basketball For Family Fun
Variations Of Basketball For Family FunVariations Of Basketball For Family Fun
Variations Of Basketball For Family Fun
 
AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax Algorithm
 
How to Play Cornhole
How to Play CornholeHow to Play Cornhole
How to Play Cornhole
 
Pradunma daa
Pradunma daaPradunma daa
Pradunma daa
 
Sports
Sports Sports
Sports
 
Math project
Math projectMath project
Math project
 
The Joy of Bocce
The Joy of BocceThe Joy of Bocce
The Joy of Bocce
 
Football strategy 2017 pdf
Football strategy 2017 pdfFootball strategy 2017 pdf
Football strategy 2017 pdf
 
Ig1 task 2 analysis work sheet 04
Ig1 task 2 analysis work sheet 04Ig1 task 2 analysis work sheet 04
Ig1 task 2 analysis work sheet 04
 

Andere mochten auch

Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingMike Clement
 
Put the Tests Before the Code
Put the Tests Before the CodePut the Tests Before the Code
Put the Tests Before the CodeMike Clement
 
Software Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code GamesSoftware Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code GamesMike Clement
 
Play to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and DicePlay to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and DiceMike Clement
 
Transformation Priority Premise: TDD Test Order Matters
Transformation Priority Premise: TDD Test Order MattersTransformation Priority Premise: TDD Test Order Matters
Transformation Priority Premise: TDD Test Order MattersMike Clement
 
Power of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) PatternsPower of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) PatternsMike Clement
 
FizzBuzz Guided Kata
FizzBuzz Guided KataFizzBuzz Guided Kata
FizzBuzz Guided KataMike Clement
 
The Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at PluralsightThe Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at PluralsightMike Clement
 
Mob Programming for Continuous Learning
Mob Programming for Continuous LearningMob Programming for Continuous Learning
Mob Programming for Continuous LearningMike Clement
 

Andere mochten auch (9)

Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit Testing
 
Put the Tests Before the Code
Put the Tests Before the CodePut the Tests Before the Code
Put the Tests Before the Code
 
Software Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code GamesSoftware Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code Games
 
Play to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and DicePlay to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and Dice
 
Transformation Priority Premise: TDD Test Order Matters
Transformation Priority Premise: TDD Test Order MattersTransformation Priority Premise: TDD Test Order Matters
Transformation Priority Premise: TDD Test Order Matters
 
Power of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) PatternsPower of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) Patterns
 
FizzBuzz Guided Kata
FizzBuzz Guided KataFizzBuzz Guided Kata
FizzBuzz Guided Kata
 
The Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at PluralsightThe Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at Pluralsight
 
Mob Programming for Continuous Learning
Mob Programming for Continuous LearningMob Programming for Continuous Learning
Mob Programming for Continuous Learning
 

Ähnlich wie Thinking in F#

Jeff parkeredu653bowling
Jeff parkeredu653bowlingJeff parkeredu653bowling
Jeff parkeredu653bowlingJeffPCMU
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ projectUtkarsh Aggarwal
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdfaquacareser
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdfaquapariwar
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - pythonSunjid Hasan
 
Software craftsmanship - 4
Software craftsmanship - 4Software craftsmanship - 4
Software craftsmanship - 4Uri Lavi
 
TornadoBrickSmasherUserManual
TornadoBrickSmasherUserManualTornadoBrickSmasherUserManual
TornadoBrickSmasherUserManualClayton Schembri
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxNayanChandak1
 
Game mechanics-puzzles (NielsQuinten)
Game mechanics-puzzles (NielsQuinten)Game mechanics-puzzles (NielsQuinten)
Game mechanics-puzzles (NielsQuinten)lieveachten
 

Ähnlich wie Thinking in F# (17)

Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
 
Jeff parkeredu653bowling
Jeff parkeredu653bowlingJeff parkeredu653bowling
Jeff parkeredu653bowling
 
MAPEH PE Mod3.pdf
MAPEH PE Mod3.pdfMAPEH PE Mod3.pdf
MAPEH PE Mod3.pdf
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
 
Basic practice of R
Basic practice of RBasic practice of R
Basic practice of R
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Games thiagi
Games thiagiGames thiagi
Games thiagi
 
Software craftsmanship - 4
Software craftsmanship - 4Software craftsmanship - 4
Software craftsmanship - 4
 
TornadoBrickSmasherUserManual
TornadoBrickSmasherUserManualTornadoBrickSmasherUserManual
TornadoBrickSmasherUserManual
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptx
 
AI Lesson 07
AI Lesson 07AI Lesson 07
AI Lesson 07
 
Game mechanics-puzzles (NielsQuinten)
Game mechanics-puzzles (NielsQuinten)Game mechanics-puzzles (NielsQuinten)
Game mechanics-puzzles (NielsQuinten)
 
Two player games
Two player gamesTwo player games
Two player games
 

Mehr von Mike Clement

Collaboration Principles from Mob Programming
Collaboration Principles from Mob ProgrammingCollaboration Principles from Mob Programming
Collaboration Principles from Mob ProgrammingMike Clement
 
Focus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in ActionFocus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in ActionMike Clement
 
Taming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touchTaming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touchMike Clement
 
Develop your sense of code smell
Develop your sense of code smellDevelop your sense of code smell
Develop your sense of code smellMike Clement
 
Maps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big PictureMaps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big PictureMike Clement
 
Escaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product DevelopmentEscaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product DevelopmentMike Clement
 
Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012Mike Clement
 
Linq (from the inside)
Linq (from the inside)Linq (from the inside)
Linq (from the inside)Mike Clement
 
Bowling Game Kata in C# Adapted
Bowling Game Kata in C# AdaptedBowling Game Kata in C# Adapted
Bowling Game Kata in C# AdaptedMike Clement
 
Code Katas: Practicing Your Craft
Code Katas: Practicing Your CraftCode Katas: Practicing Your Craft
Code Katas: Practicing Your CraftMike Clement
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software CraftsmanshipMike Clement
 

Mehr von Mike Clement (11)

Collaboration Principles from Mob Programming
Collaboration Principles from Mob ProgrammingCollaboration Principles from Mob Programming
Collaboration Principles from Mob Programming
 
Focus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in ActionFocus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in Action
 
Taming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touchTaming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touch
 
Develop your sense of code smell
Develop your sense of code smellDevelop your sense of code smell
Develop your sense of code smell
 
Maps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big PictureMaps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big Picture
 
Escaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product DevelopmentEscaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product Development
 
Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012
 
Linq (from the inside)
Linq (from the inside)Linq (from the inside)
Linq (from the inside)
 
Bowling Game Kata in C# Adapted
Bowling Game Kata in C# AdaptedBowling Game Kata in C# Adapted
Bowling Game Kata in C# Adapted
 
Code Katas: Practicing Your Craft
Code Katas: Practicing Your CraftCode Katas: Practicing Your Craft
Code Katas: Practicing Your Craft
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 

Kürzlich hochgeladen

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 

Kürzlich hochgeladen (20)

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 

Thinking in F#

  • 1. Thinking in F# Mike Clement @mdclement mike@softwareontheside.com http://blog.softwareontheside.com
  • 2. XP Simple Design •Passes all tests •Clear, expressive, consistent •No duplication •Minimal
  • 3. FizzBuzz • If multiple of 3, get “Fizz” • If multiple of 5, get “Buzz” • If not, return input int as string • Rules are in order
  • 5. Currying/Partial function application let Multiples divisor result x s = if x % divisor = 0 then s + result else s let Fizzy = Multiples 3 "Fizz" val Multiples : divisor:int -> result:string -> x:int -> s:string -> string val Fizzy : (int -> string -> string) let Fizzy x s = if x % 3 = 0 then s + "Fizz" else s
  • 6. Bowling Game Kata The game consists of 10 frames as shown above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares. A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knocked down) plus a bonus of 5 (the number of pins knocked down on the next roll.) A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled. In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
  • 7. Bowling Game – The OO Way
  • 8. Bowling Game How do we get more functional?
  • 9. Lists [1, 2, 3, 4] Head Tail
  • 10. Lists [1, 2, 3, 4].Head = 1 [1, 2, 3, 4].Tail = [2, 3, 4] [1, 2, 3, 4].Tail.Tail = [3, 4]
  • 11. F# Resources • http://en.wikibooks.org/wiki/F_Sharp_Programming • F# for C# Developers by Tao Liu • http://www.tryfsharp.org/ • https://github.com/ChrisMarinos/FSharpKoans
  • 12. Mike Clement • @mdclement • mike@softwareontheside.com • http://blog.softwareontheside.com • https://github.com/mdclement • http://agilecodegames.com • Utah Software Craftsmanship • http://utahsc.org • @utahsc • We meet the first Wednesday at SLCC

Hinweis der Redaktion

  1. Start here. Do the simplest thing that works.Can F# help me with this?
  2. Have the room count off
  3. Currying is built on the principle that each argument actually returns a separate function, which is why calling a function with only part of its parameters returns another function.