SlideShare a Scribd company logo
1 of 48
F# on the Road to Visual Studio
             2010
    Robert Pickering – LexiFi (ALTi)

    With thanks to Don Syme, Leon
  “secretGeek” Bambrick, Chris Smith
           and the puppies
Session Overview
• Why was F# created? Why learn F#?

• A taste of the F# language
  – Especially the functional side!


• See a complete working F# “Collective
  Intelligence” application
Part 1




F#...

Do not be afraid.
hello
I’m F#
I'll let you in on a secret: I'm doing F# simply
because it's lots and lots of fun. In a very broad
sense of the word: functional programming is
fun, OO programming with F# is fun, watching
people use F# is fun.
One of the wonderful things about F# is that you
can actually end up working in your domain. In
the zone. With F#, you're not necessarily quot;justquot; a
programmer! You're likely to also be a
probabilistic modeller, or an AutoCAD
engineer, or a finance engineer, or a symbolic
programmer, or one of many other things.
                         - Don Syme,
                         F#’s creator
F# is unique amongst both imperative and
declarative languages in that it is the golden
middle road where these two extremes converge.
F# takes the best features of both paradigms and
tastefully combines them in a highly productive
and elegant language that both scientists and
developers identify with. F# makes programmers
better mathematicians and mathematicians
better programmers.

         - Eric Meijer,
         Forward to Expert F#
A Few Words From …




Julien Laugel
Head of Research & Development
EuroPerformance
F#: Combining Paradigms
I've been coding in F# lately, for a production task.

F# allows you to move smoothly in your programming style... I start
with pure functional code, shift slightly towards an object-oriented
style, and in production code, I sometimes have to do some
imperative programming.

I can start with a pure idea, and still finish my project with realistic
code. You're never disappointed in any phase of the project!

             Julien Laugel, Head of Research & Development, EuroPerformance
F#: Influences



OCaml              F#                C#/.NET



    Similar core    Similar object
       language          model
Road Map
• Current Release: September CTP for VS 2008

• Next Release: as part of VS 2010 beta 1

• Plugin for VS Shell and CodePlex release in VS
  2010 timeframe

• More:
http://blogs.msdn.com/dsyme/archive/2008/12/10/fsharp-to-ship-as-part-of-visual-studio-2010.aspx
Part 2




F# the Language ...


         ... and the Functional
                     Point of View
Code!
//F#                   //C#
open System            using System;
let a = 2
                       namespace ConsoleApplication1
Console.WriteLine a    {
                         class Program
                         {
                           static int a()
                           {
                               return 2;
                           }
                           static void Main(string[] args)
                           {
                               Console.WriteLine(a);
                           }
                         }
                       }
More Code!
//F#
open System
let a = 2
Console.WriteLine a



                                   a

                                    2




                             Console.WriteLine a


              More Noise
              Than Signal!
Let Bindings & Literals
Declaration
                 An identifier       A comment
of a binding

       let aString     = quot;Stringyquot;    // a string




 Like “var” in
                         A literal
      C#
Lists
Let binding
                             The empty
// the empty list
let emptyList = []              list

    Literal    Concatenate
                                 The empty
                                    list
// adding to a list
let conact = quot;Onequot; :: []
Lists


let list = 1 :: 2 :: 3 :: []

                               These are
                                the same

let list = [1; 2; 3]
Functions
              Parameter


// a function
let addTen = fun x -> x + 10



Let binding               Result
Functions

     Parameter

// shorter version
let addTen x = x + 10



Let binding             Result
Functions
  Let binding        Parameters

// multi parameters and
// intermediate results
let addThenTimesTwo x y =
    let temp = x + y           Intermediate
    temp * 2                       Value


 Whitespace
  Sensitive           Result
Pattern Matching
        // simple pattern matching
        let matching n =
            match n with
            | 1 -> quot;Onequot;
Pattern     | 2 -> quot;Twoquot;         Result
            | _ -> quot;Otherquot;
Pattern Matching
          // pattern matching               Recursive
          // over lists
          let rec addOne list =             function
Pattern       match list with
              | head :: tail ->
                  head + 1 :: addOne tail
              | [] -> []
Result                                  Recursive call
          // more pattern matching
          // over lists
          let rec subOne list =
              match list with
              | head :: tail ->
                  head - 1 :: subOne tail
              | [] -> []
DRY!

D on’t
R eapt
Y ourself


            (ML is 23 years older than Ruby)
Functions as Parameters
                 // pattern matching              Function
                 // over lists
                 let rec map func list =         parameter
                     match list with
                     | head :: tail ->
Call function            func head :: map tail
                     | [] -> []




let addOne list = List.map (fun x -> x + 1) list


let subOne list = List.map (fun x -> x + 1) list
Part 3




A “Collective Intelligence”
Example Application

Classifying the Bloggers
Representing a Blog
• A blog can be represented by the frequency
  that words appear in it
• Most and least common words are cut
   – words like “the” are ignored
   – words like “woah” are ignored

                             Phone   Email   Book   People   Affiliate
 Heckler Spray               0       0       1      2        0
 Shiny Shiny                 3       0       0      5        0
 Chris Garret on New Media   1       75      12     60       24
Measuring “Closeness” of Blogs
                             People

        Chris Garret on New Media




                                    Heckler Spray




Email                                               Book
Measuring “Closeness” of Blogs
• Pervious slide shows “Euclidean Distance”
• While this could be use we use “Pearson
  correlation”
  – “Pearson correlation” corrects for the problem
    that some blogs are longer than others




           where
Pearson correlation in F#
let pearson (wc1: seq<float>) (wc2: seq<float>) =
    let sum = PSeq.reduce (+)
    let sum1 = sum wc1
    let sum2 = sum wc2

   let sumSq1 = sum (Seq.map (fun x -> x * x) wc1)
   let sumSq2 = sum (Seq.map (fun x -> x * x) wc2)

   let pSum = sum (Seq.map2 (fun x y -> x * y) wc1 wc2)

   let len = float (Seq.length wc1)
   let num = pSum - ((sum1 * sum2) / len)
   let den = sqrt ((sumSq1 - (sum1 * sum1) / len)
                   * (sumSq2 - (sum2 * sum2) / len))
   if den = 0. then 0. else num / den
Hierarchical Clustering

A       B       A       B   A       B   A       B

    C               C           C           C


D       E       D       E   D       E   D       E




                                        A       B

                                            C


                                        D       E
Viewing the Hierarchical Clustering
                             A


                             B


                             C



                             D


                             E
How we implement hierarchical clustering efficiently in F#

THE ALGORITHM
Map                          Reduce

        Fetch Data     Process Data               Build Tree




Start                                                           End



                      Clean Data
                                                Calculate Words Used
                      Split Data
 Make HTTP Request                              Build Tree
                      Count Word
                      Create Master Word List
Map                         Reduce

        Fetch Data           Process Data        Build Tree




Start                                                             End




                                                 Parallelized by the
        Parallelized by Asynchronous Workflows
                                                 Parallel Task Library
3 Layer Architecture

      Data Access – dataAccess.fs
                                               Helpers
                                             extentions.fs
        Business Logic – algo.fs



UI – Program.fs           Tests – test.fsx
Hierarchical clustering application in action

DEMO
Application Metrics
• Helper/Extension Code: ~60 lines

• Data Access Code: ~30 lines

• Main algorithm: ~220 lines

• UI code: ~150 lines (F#) / ~40 lines (XAML)
Other Things To Cluster
• Any other kind of text:
   – Books from project Gutenberg
   – Twitter!
   – Messages boards or other web pages

• People in social networks

• Reviewers on Amazon

• Companies based on metrics
Collective Intelligence
      By Toby Segaran
Part 3




End Bit
msdn.microsoft.com/fsharp/
F# Resources
•   MDSN Resource center: http://msdn.microsoft.com/fsharp/

•   User forums: http://cs.hubfs.net/forums

•    Blogs (there are lots of others!):
    •    http://blogs.msnd.com/dsyme
    •    http://strangelights.com/blog

•    Samples on the web:
    •   http://code.msdn.microsoft.com/fsharpsamples
    •   http://code.google.com/hosting/search?q=label:fsharp
    •   http://codeplex.com/Project/ProjectDirectory.aspx?TagName=F%23

•    Source available with the distribution: %ProgramFiles%FSharp-1.9.6.2source
Current Books about F#
Books to come about F#




Second Edition
alt.net.france
Program:
• 18 February: Aspectize – Frédéric Fadel –
  Winwise, 16 rue Gaillon 75002 Paris
• 18 March: TDD – Djamel Zouaoui – chez OCTO
  Technology, 50 avenue des champs Elysées
• 22 April: Entity Framework – Matthieu MEZIL
• More info:
  http://groups.google.com/group/parisaltnet
Questions?

More Related Content

What's hot

Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++somu rajesh
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesEelco Visser
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric SystemErin Dees
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
Subroutines in perl
Subroutines in perlSubroutines in perl
Subroutines in perlsana mateen
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#bleis tift
 
C++ Overview
C++ OverviewC++ Overview
C++ Overviewkelleyc3
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)bolovv
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesEelco Visser
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco Visser
 
Doscommands
DoscommandsDoscommands
DoscommandsDurgule
 
C++ language basic
C++ language basicC++ language basic
C++ language basicWaqar Younis
 
Thnad's Revenge
Thnad's RevengeThnad's Revenge
Thnad's RevengeErin Dees
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern PerlDave Cross
 
Advanced Programming C++
Advanced Programming C++Advanced Programming C++
Advanced Programming C++guestf0562b
 

What's hot (20)

Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric System
 
C++
C++C++
C++
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Subroutines in perl
Subroutines in perlSubroutines in perl
Subroutines in perl
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
C++ theory
C++ theoryC++ theory
C++ theory
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
Data types in c++
Data types in c++ Data types in c++
Data types in c++
 
Doscommands
DoscommandsDoscommands
Doscommands
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Thnad's Revenge
Thnad's RevengeThnad's Revenge
Thnad's Revenge
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern Perl
 
Advanced Programming C++
Advanced Programming C++Advanced Programming C++
Advanced Programming C++
 
3 Function Overloading
3 Function Overloading3 Function Overloading
3 Function Overloading
 

Viewers also liked

&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...
&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...
&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...Lsiedlick
 
Users, Prototyping, Etc. (Lean Startup Machine Toronto)
Users, Prototyping, Etc. (Lean Startup Machine Toronto)Users, Prototyping, Etc. (Lean Startup Machine Toronto)
Users, Prototyping, Etc. (Lean Startup Machine Toronto)Satish Kanwar
 
&quot;Capturing Your Market&quot; - 2006 Washington G2
&quot;Capturing Your Market&quot; -  2006 Washington G2&quot;Capturing Your Market&quot; -  2006 Washington G2
&quot;Capturing Your Market&quot; - 2006 Washington G2Lsiedlick
 
Conclusioni
ConclusioniConclusioni
ConclusioniFabeo
 
&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...
&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...
&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...Lsiedlick
 
L Siedlick2009 Film Final
L Siedlick2009 Film FinalL Siedlick2009 Film Final
L Siedlick2009 Film FinalLsiedlick
 
1 litterature ancienne introduction (2) (1)
1 litterature ancienne introduction (2) (1)1 litterature ancienne introduction (2) (1)
1 litterature ancienne introduction (2) (1)LITTPOL
 
Réseaux sociaux et imprimeurs: les bonnes pratiques
Réseaux sociaux et imprimeurs: les bonnes pratiquesRéseaux sociaux et imprimeurs: les bonnes pratiques
Réseaux sociaux et imprimeurs: les bonnes pratiqueshellollb
 

Viewers also liked (9)

xDxD
xDxDxDxD
xDxD
 
&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...
&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...
&quot;Connecting the Dots for Success&quot; - 2007 American Association of Bi...
 
Users, Prototyping, Etc. (Lean Startup Machine Toronto)
Users, Prototyping, Etc. (Lean Startup Machine Toronto)Users, Prototyping, Etc. (Lean Startup Machine Toronto)
Users, Prototyping, Etc. (Lean Startup Machine Toronto)
 
&quot;Capturing Your Market&quot; - 2006 Washington G2
&quot;Capturing Your Market&quot; -  2006 Washington G2&quot;Capturing Your Market&quot; -  2006 Washington G2
&quot;Capturing Your Market&quot; - 2006 Washington G2
 
Conclusioni
ConclusioniConclusioni
Conclusioni
 
&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...
&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...
&quot;Leadership in the Modern Pathology Environment&quot; - 2009 Siemens Aca...
 
L Siedlick2009 Film Final
L Siedlick2009 Film FinalL Siedlick2009 Film Final
L Siedlick2009 Film Final
 
1 litterature ancienne introduction (2) (1)
1 litterature ancienne introduction (2) (1)1 litterature ancienne introduction (2) (1)
1 litterature ancienne introduction (2) (1)
 
Réseaux sociaux et imprimeurs: les bonnes pratiques
Réseaux sociaux et imprimeurs: les bonnes pratiquesRéseaux sociaux et imprimeurs: les bonnes pratiques
Réseaux sociaux et imprimeurs: les bonnes pratiques
 

Similar to Tech Days Paris Intoduction F# and Collective Intelligence

Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Robert Pickering
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?lichtkind
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellBryan O'Sullivan
 
C language by Dr. D. R. Gholkar
C language by Dr. D. R. GholkarC language by Dr. D. R. Gholkar
C language by Dr. D. R. GholkarPRAVIN GHOLKAR
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005Tugdual Grall
 
Introduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users groupIntroduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users groupPaul Richards
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)Sami Said
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
C prog ppt
C prog pptC prog ppt
C prog pptxinoe
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 

Similar to Tech Days Paris Intoduction F# and Collective Intelligence (20)

Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
python and perl
python and perlpython and perl
python and perl
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
C Programming
C ProgrammingC Programming
C Programming
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
 
Php
PhpPhp
Php
 
C language by Dr. D. R. Gholkar
C language by Dr. D. R. GholkarC language by Dr. D. R. Gholkar
C language by Dr. D. R. Gholkar
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
Introduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users groupIntroduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users group
 
lab4_php
lab4_phplab4_php
lab4_php
 
lab4_php
lab4_phplab4_php
lab4_php
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Effective Object Oriented Design in Cpp
Effective Object Oriented Design in CppEffective Object Oriented Design in Cpp
Effective Object Oriented Design in Cpp
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
C prog ppt
C prog pptC prog ppt
C prog ppt
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Tech Days Paris Intoduction F# and Collective Intelligence

  • 1. F# on the Road to Visual Studio 2010 Robert Pickering – LexiFi (ALTi) With thanks to Don Syme, Leon “secretGeek” Bambrick, Chris Smith and the puppies
  • 2. Session Overview • Why was F# created? Why learn F#? • A taste of the F# language – Especially the functional side! • See a complete working F# “Collective Intelligence” application
  • 3. Part 1 F#... Do not be afraid.
  • 6.
  • 7.
  • 8. I'll let you in on a secret: I'm doing F# simply because it's lots and lots of fun. In a very broad sense of the word: functional programming is fun, OO programming with F# is fun, watching people use F# is fun. One of the wonderful things about F# is that you can actually end up working in your domain. In the zone. With F#, you're not necessarily quot;justquot; a programmer! You're likely to also be a probabilistic modeller, or an AutoCAD engineer, or a finance engineer, or a symbolic programmer, or one of many other things. - Don Syme, F#’s creator
  • 9. F# is unique amongst both imperative and declarative languages in that it is the golden middle road where these two extremes converge. F# takes the best features of both paradigms and tastefully combines them in a highly productive and elegant language that both scientists and developers identify with. F# makes programmers better mathematicians and mathematicians better programmers. - Eric Meijer, Forward to Expert F#
  • 10. A Few Words From … Julien Laugel Head of Research & Development EuroPerformance
  • 11. F#: Combining Paradigms I've been coding in F# lately, for a production task. F# allows you to move smoothly in your programming style... I start with pure functional code, shift slightly towards an object-oriented style, and in production code, I sometimes have to do some imperative programming. I can start with a pure idea, and still finish my project with realistic code. You're never disappointed in any phase of the project! Julien Laugel, Head of Research & Development, EuroPerformance
  • 12. F#: Influences OCaml F# C#/.NET Similar core Similar object language model
  • 13. Road Map • Current Release: September CTP for VS 2008 • Next Release: as part of VS 2010 beta 1 • Plugin for VS Shell and CodePlex release in VS 2010 timeframe • More: http://blogs.msdn.com/dsyme/archive/2008/12/10/fsharp-to-ship-as-part-of-visual-studio-2010.aspx
  • 14. Part 2 F# the Language ... ... and the Functional Point of View
  • 15. Code! //F# //C# open System using System; let a = 2 namespace ConsoleApplication1 Console.WriteLine a { class Program { static int a() { return 2; } static void Main(string[] args) { Console.WriteLine(a); } } }
  • 16. More Code! //F# open System let a = 2 Console.WriteLine a a 2 Console.WriteLine a More Noise Than Signal!
  • 17. Let Bindings & Literals Declaration An identifier A comment of a binding let aString = quot;Stringyquot; // a string Like “var” in A literal C#
  • 18. Lists Let binding The empty // the empty list let emptyList = [] list Literal Concatenate The empty list // adding to a list let conact = quot;Onequot; :: []
  • 19. Lists let list = 1 :: 2 :: 3 :: [] These are the same let list = [1; 2; 3]
  • 20. Functions Parameter // a function let addTen = fun x -> x + 10 Let binding Result
  • 21. Functions Parameter // shorter version let addTen x = x + 10 Let binding Result
  • 22. Functions Let binding Parameters // multi parameters and // intermediate results let addThenTimesTwo x y = let temp = x + y Intermediate temp * 2 Value Whitespace Sensitive Result
  • 23. Pattern Matching // simple pattern matching let matching n = match n with | 1 -> quot;Onequot; Pattern | 2 -> quot;Twoquot; Result | _ -> quot;Otherquot;
  • 24. Pattern Matching // pattern matching Recursive // over lists let rec addOne list = function Pattern match list with | head :: tail -> head + 1 :: addOne tail | [] -> [] Result Recursive call // more pattern matching // over lists let rec subOne list = match list with | head :: tail -> head - 1 :: subOne tail | [] -> []
  • 25. DRY! D on’t R eapt Y ourself (ML is 23 years older than Ruby)
  • 26. Functions as Parameters // pattern matching Function // over lists let rec map func list = parameter match list with | head :: tail -> Call function func head :: map tail | [] -> [] let addOne list = List.map (fun x -> x + 1) list let subOne list = List.map (fun x -> x + 1) list
  • 27. Part 3 A “Collective Intelligence” Example Application Classifying the Bloggers
  • 28. Representing a Blog • A blog can be represented by the frequency that words appear in it • Most and least common words are cut – words like “the” are ignored – words like “woah” are ignored Phone Email Book People Affiliate Heckler Spray 0 0 1 2 0 Shiny Shiny 3 0 0 5 0 Chris Garret on New Media 1 75 12 60 24
  • 29. Measuring “Closeness” of Blogs People Chris Garret on New Media Heckler Spray Email Book
  • 30. Measuring “Closeness” of Blogs • Pervious slide shows “Euclidean Distance” • While this could be use we use “Pearson correlation” – “Pearson correlation” corrects for the problem that some blogs are longer than others where
  • 31. Pearson correlation in F# let pearson (wc1: seq<float>) (wc2: seq<float>) = let sum = PSeq.reduce (+) let sum1 = sum wc1 let sum2 = sum wc2 let sumSq1 = sum (Seq.map (fun x -> x * x) wc1) let sumSq2 = sum (Seq.map (fun x -> x * x) wc2) let pSum = sum (Seq.map2 (fun x y -> x * y) wc1 wc2) let len = float (Seq.length wc1) let num = pSum - ((sum1 * sum2) / len) let den = sqrt ((sumSq1 - (sum1 * sum1) / len) * (sumSq2 - (sum2 * sum2) / len)) if den = 0. then 0. else num / den
  • 32. Hierarchical Clustering A B A B A B A B C C C C D E D E D E D E A B C D E
  • 33. Viewing the Hierarchical Clustering A B C D E
  • 34. How we implement hierarchical clustering efficiently in F# THE ALGORITHM
  • 35. Map Reduce Fetch Data Process Data Build Tree Start End Clean Data Calculate Words Used Split Data Make HTTP Request Build Tree Count Word Create Master Word List
  • 36. Map Reduce Fetch Data Process Data Build Tree Start End Parallelized by the Parallelized by Asynchronous Workflows Parallel Task Library
  • 37. 3 Layer Architecture Data Access – dataAccess.fs Helpers extentions.fs Business Logic – algo.fs UI – Program.fs Tests – test.fsx
  • 39. Application Metrics • Helper/Extension Code: ~60 lines • Data Access Code: ~30 lines • Main algorithm: ~220 lines • UI code: ~150 lines (F#) / ~40 lines (XAML)
  • 40. Other Things To Cluster • Any other kind of text: – Books from project Gutenberg – Twitter! – Messages boards or other web pages • People in social networks • Reviewers on Amazon • Companies based on metrics
  • 41. Collective Intelligence By Toby Segaran
  • 44. F# Resources • MDSN Resource center: http://msdn.microsoft.com/fsharp/ • User forums: http://cs.hubfs.net/forums • Blogs (there are lots of others!): • http://blogs.msnd.com/dsyme • http://strangelights.com/blog • Samples on the web: • http://code.msdn.microsoft.com/fsharpsamples • http://code.google.com/hosting/search?q=label:fsharp • http://codeplex.com/Project/ProjectDirectory.aspx?TagName=F%23 • Source available with the distribution: %ProgramFiles%FSharp-1.9.6.2source
  • 46. Books to come about F# Second Edition
  • 47. alt.net.france Program: • 18 February: Aspectize – Frédéric Fadel – Winwise, 16 rue Gaillon 75002 Paris • 18 March: TDD – Djamel Zouaoui – chez OCTO Technology, 50 avenue des champs Elysées • 22 April: Entity Framework – Matthieu MEZIL • More info: http://groups.google.com/group/parisaltnet

Editor's Notes

  1. What’s this F# thing anyway?
  2. It’s a general purpose language, ideal for real world development. Built in .Net. Officially supported.
  3. It’s a general purpose language, ideal for real world development. Built in .Net. Officially supported.
  4. It’s a general purpose language, ideal for real world development. Built in .Net. Officially supported.