SlideShare a Scribd company logo
F# and Silverlight Talbott Crowell F# User Group, April 5, 2010http://fsug.org
QuickIntro to F# Calculating Moving Average in F# Quick Intro to Silverlight Visualizing F# Using Silverlight Toolkit Agenda
Quick Intro to F#
Functional language developed by Microsoft Research 2002 language design started by Don Syme 2005 F# 1.0.1 public release (integration w/ VS2003) 2010 F# is “productized” and baked into VS2010 Multi-paradigm Functional/Imperative/OO/Language Oriented Key characteristics Succinct, Type Inference (strongly typed), 1st class functions What is F#
Type inferencing Strong typed Functions as values F# Intro b is a float let a = 5 let b = 6.0 let c = “7 feet” let d x = x * x let e = d b d is a function What data type is e?
The |> Combinator “Pipe Forward”  Example F# Combinators  x |> f       is the same as       f x   let sqr x = x * x sqr 5   5 |> sqr
Moving Average in F#
Start with a list of numbers Moving Average step 1 let testdata = [1.0 .. 10.0] testdata is a list of floats
Create windows of the series Moving Average step 2 Seq.windowed 4 testdata it is a sequence of float arrays
Average the values in each array Moving Average step 3 Array.average [|1.0; 2.0; 3.0; 4.0|]
Use Seq.map to calculate average of all arrays in the sequence Moving Average step 4 let windowedData = Seq.windowed period data Seq.map Array.averagewindowedData the first argument is the function to apply to each item in the sequence the second argument is the sequence
Use the pipe forward operator to put it together and omit the let Moving Average step 5 Seq.windowed period data  |> Seq.map Array.average
Put our algorithm into a function and test it Moving Average function let MovingAverage period data = Seq.windowed period data      |> Seq.map Array.average let testdata = [1.0 .. 10.0] let test = MovingAverage 4 testdata
Let’s generate some random data open System let GenerateData offset variance count =      let rnd = new Random()     let randomDouble variance = rnd.NextDouble() * variance     let indexes = Seq.ofList [0..(count-1)]     let genValuei =          let value = float i + offset + randomDouble variance         value     Seq.map genValue indexes let dataGenerator = GenerateData 50.0 100.0 200
Putting it together let data1 = List.ofSeqdataGenerator let data2 = List.ofSeq <| MovingAverage 10 data1
Time to visualize…
Quick Intro to Silverlight
What is Silverlight? Microsoft RIA plug-in for browsers 2007 Version 1.0 JavaScript based 2008 Version 2.0 .NET based 2009 Version 3.0 more controls, out of browser support (offline) 2010 Version 4.0 printing, COM, Multi-touch Runs on multiple browsers/OS IE, Safari, Firefox, Chrome / Win, MacOS, Linux* ,[object Object]
WPF/E (original name),[object Object]
Visual Studio 2008 Using Luke Hoban’s F# Silverlight templates Visual Studio 2010 RC Built-in F# Support for Silverlight in VS http://code.msdn.microsoft.com/fsharpsilverlight
Silverlight Toolkit http://silverlight.codeplex.com/ Silverlight SDK Silverlight 3 SDK Silverlight 4 SDK Beta Graphing Controls
Visualizing F# using Silverlight Toolkit
Use the “Silverlight Application” template in Visual Studio Creates Silverlight Application (produces XAP) Creates Web Application (hosts web site and XAP) Create a Silverlight Application
 Initial UserControl Notice XML Namespaces (need to add more) XAML
Add References
Add namespaces to XAML to support Silverlight Toolkit xmlns:controls="clr-namespace: System.Windows.Controls; assembly=System.Windows.Controls" xmlns:controlsToolkit="clr-namespace: System.Windows.Controls; assembly=System.Windows.Controls.Toolkit" xmlns:chartingToolkit="clr-namespace: System.Windows.Controls.DataVisualization.Charting; assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:chartingPrimitivesToolkit="clr-namespace: System.Windows.Controls.DataVisualization.Charting.Primitives; assembly=System.Windows.Controls.DataVisualization.Toolkit"
Sample Series comes from Static Resource. Define Static Resource in App.xaml Add a chart to MainPage.xaml
add namespace add sample dataset Static Resource App.xaml
Similar to a Class Library project except it compiles with special options to target the Silverlight CLR Use file links to share F# files between Class Library and Silverlight Library Add Existing File Choose “Add As Link” from dropdown Create an F# Silverlight Library
SeriesDataPoint is a class (type) that has two members, Index and Value Used for series data Add Chart Helper type SeriesDataPoint(index, value) =     member this.Index with get() = index     member this.Value with get() = value
Used by XAML Designer to bind at design time Add Sample Data Set type SampleDataSet() =     static member SampleSeries1 =         let data = new ObjectCollection() data.Add(new SeriesDataPoint(0, 124.1)) data.Add(new SeriesDataPoint(1, 124.3)) data.Add(new SeriesDataPoint(2, 125.7)) data.Add(new SeriesDataPoint(3, 115.4)) data.Add(new SeriesDataPoint(4, 115.9)) data.Add(new SeriesDataPoint(5, 125.0)) data.Add(new SeriesDataPoint(6, 133.6)) data.Add(new SeriesDataPoint(7, 131.9)) data.Add(new SeriesDataPoint(8, 127.3)) data.Add(new SeriesDataPoint(9, 137.3))         data
Designer is now binding with F#
Code behind for MainPage.xaml Use constructor to wire up events Add code behind for MainPage public partial class MainPage : UserControl {    public MainPage()    { InitializeComponent(); SilverlightEvents.RegisterHandlers(this.LayoutRoot);    } }
Event handling code for application in F# SilverlightEvents in F#
Sample Button Click Event buttonGenerateSampleData.Click.Add(fun(_) ->    let data = GenerateDataPoints 125.0 10.0 10    let series = DataConverter.ConvertDataPointsToLineSeries        "Sample Series 3" data chart.Series.Add(series)    )
Slider Events - Mouse slider.MouseLeftButtonUp.Add(fun(_) -> model.UpdateSeries()) member internal this.UpdateSeries() = m_range <- (intslider.Value)    let movingAverage = MovingAveragem_rangem_data    let newSeries = this.GetMovingAverageSeriesmovingAverage chart.Series.[1] <- newSeries    ()
Slider Events – Value Changed slider.ValueChanged.Add(fun(callback) -> model.UpdateMovingAverage(callback)) member this.UpdateMovingAverage(args:RoutedPropertyChangedEventArgs<float>) =         let oldVal = intargs.OldValue         let newVal = intargs.NewValue         if oldVal = newVal then             () elif (Math.Abs(oldVal - newVal) > 4) then m_range <- newVal this.UpdateSeries()             ()         else m_range <- newVal             ()
Generate Data and Moving Average
Getting Started http://www.silverlight.net/getstarted/silverlight-4/ Tim Heuer’s Blog http://timheuer.com/blog/archive/2010/03/15/whats-new-in-silverlight-4-rc-mix10.aspx Silverlight 4 and Visual Studio 2010 RC
Bart Czernicki’s Silverlight Hack Blog http://www.silverlighthack.com/post/2009/11/04/Silverlight-3-and-FSharp-Support-in-Visual-Studio-2010.aspx Luke Hoban’s WebLog http://blogs.msdn.com/lukeh/archive/2009/06/26/f-in-silverlight.aspx support for F# in VS 2008 http://code.msdn.microsoft.com/fsharpsilverlight F# and Silverlight 2.0 http://jyliao.blogspot.com/2008/11/f-and-silverlight-20.html Other Helpful Links
http://fsug.org Thank you. Questions?F# and Silverlight Talbott Crowell ThirdM.com http://talbottc.spaces.live.com Twitter: @talbottand @fsug

More Related Content

What's hot

Project of data structure
Project of data structureProject of data structure
Project of data structure
Umme habiba
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
Lovely Professional University
 
Data Structure (Stack)
Data Structure (Stack)Data Structure (Stack)
Data Structure (Stack)
Adam Mukharil Bachtiar
 
Sql FUNCTIONS
Sql FUNCTIONSSql FUNCTIONS
Sql FUNCTIONS
Abrar ali
 
Stack push pop
Stack push popStack push pop
Stack push pop
A. S. M. Shafi
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applicationsSaqib Saeed
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
Controllers and context programming
Controllers and context programmingControllers and context programming
Controllers and context programmingKranthi Kumar
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
Katy Slemon
 
Introduction To Stack
Introduction To StackIntroduction To Stack
Introduction To Stack
Education Front
 
Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions
Kulachi Hansraj Model School Ashok Vihar
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structurepcnmtutorials
 
The Ring programming language version 1.5.1 book - Part 20 of 180
The Ring programming language version 1.5.1 book - Part 20 of 180The Ring programming language version 1.5.1 book - Part 20 of 180
The Ring programming language version 1.5.1 book - Part 20 of 180
Mahmoud Samir Fayed
 
How to instantiate any view controller for free
How to instantiate any view controller for freeHow to instantiate any view controller for free
How to instantiate any view controller for free
BenotCaron
 
Stacks
StacksStacks
Stacks
Sadaf Ismail
 
Stack data structure
Stack data structureStack data structure
Stack data structure
rogineojerio020496
 

What's hot (18)

Project of data structure
Project of data structureProject of data structure
Project of data structure
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 
Data Structure (Stack)
Data Structure (Stack)Data Structure (Stack)
Data Structure (Stack)
 
Sql FUNCTIONS
Sql FUNCTIONSSql FUNCTIONS
Sql FUNCTIONS
 
Stack push pop
Stack push popStack push pop
Stack push pop
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Controllers and context programming
Controllers and context programmingControllers and context programming
Controllers and context programming
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
 
Introduction To Stack
Introduction To StackIntroduction To Stack
Introduction To Stack
 
Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
 
Stack and heap
Stack and heapStack and heap
Stack and heap
 
QuirksofR
QuirksofRQuirksofR
QuirksofR
 
The Ring programming language version 1.5.1 book - Part 20 of 180
The Ring programming language version 1.5.1 book - Part 20 of 180The Ring programming language version 1.5.1 book - Part 20 of 180
The Ring programming language version 1.5.1 book - Part 20 of 180
 
How to instantiate any view controller for free
How to instantiate any view controller for freeHow to instantiate any view controller for free
How to instantiate any view controller for free
 
Stacks
StacksStacks
Stacks
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 

Similar to F# And Silverlight

Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
Jonas Follesø
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
Dave Bost
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce Lightning
Right IT Services
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
davejohnson
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
Mike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and PatternsMike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and Patterns
ukdpe
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
Fafadia Tech
 
Windows Presentation Foundation
Windows Presentation FoundationWindows Presentation Foundation
Windows Presentation Foundation
Tran Ngoc Son
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsRobert MacLean
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
Fun2Do Labs
 
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows AzureDeveloping Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Rainer Stropek
 
Whidbey old
Whidbey old Whidbey old
Whidbey old grenaud
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#Talbott Crowell
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
Haehnchen
 
Griffon Presentation
Griffon PresentationGriffon Presentation
Griffon Presentation
Kelly Robinson
 
Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFX
Fulvio Corno
 
J2ME Lwuit, Storage & Connections (Ft Prasanjit Dey)
J2ME Lwuit, Storage & Connections (Ft   Prasanjit Dey)J2ME Lwuit, Storage & Connections (Ft   Prasanjit Dey)
J2ME Lwuit, Storage & Connections (Ft Prasanjit Dey)
Fafadia Tech
 

Similar to F# And Silverlight (20)

Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
 
Test
TestTest
Test
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce Lightning
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Mike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and PatternsMike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and Patterns
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Windows Presentation Foundation
Windows Presentation FoundationWindows Presentation Foundation
Windows Presentation Foundation
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 Enhancements
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows AzureDeveloping Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
 
Whidbey old
Whidbey old Whidbey old
Whidbey old
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Griffon Presentation
Griffon PresentationGriffon Presentation
Griffon Presentation
 
Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFX
 
J2ME Lwuit, Storage & Connections (Ft Prasanjit Dey)
J2ME Lwuit, Storage & Connections (Ft   Prasanjit Dey)J2ME Lwuit, Storage & Connections (Ft   Prasanjit Dey)
J2ME Lwuit, Storage & Connections (Ft Prasanjit Dey)
 

More from Talbott Crowell

Top 7 mistakes
Top 7 mistakesTop 7 mistakes
Top 7 mistakes
Talbott Crowell
 
Top 3 Mistakes when Building
Top 3 Mistakes when BuildingTop 3 Mistakes when Building
Top 3 Mistakes when BuildingTalbott Crowell
 
Building high performance and scalable share point applications
Building high performance and scalable share point applicationsBuilding high performance and scalable share point applications
Building high performance and scalable share point applications
Talbott Crowell
 
Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365
Talbott Crowell
 
Custom Development for SharePoint
Custom Development for SharePointCustom Development for SharePoint
Custom Development for SharePointTalbott Crowell
 
Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?
Talbott Crowell
 
Developing a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint appDeveloping a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint app
Talbott Crowell
 
Developing a provider hosted share point app
Developing a provider hosted share point appDeveloping a provider hosted share point app
Developing a provider hosted share point app
Talbott Crowell
 
Introduction to F# 3.0
Introduction to F# 3.0Introduction to F# 3.0
Introduction to F# 3.0
Talbott Crowell
 
PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012Talbott Crowell
 
PowerShell and SharePoint
PowerShell and SharePointPowerShell and SharePoint
PowerShell and SharePoint
Talbott Crowell
 
Welcome to windows 8
Welcome to windows 8Welcome to windows 8
Welcome to windows 8
Talbott Crowell
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePointTalbott Crowell
 
SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010
Talbott Crowell
 
Automating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePointAutomating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePoint
Talbott Crowell
 
Introduction to F#
Introduction to F#Introduction to F#
Introduction to F#
Talbott Crowell
 
Architecting Solutions for the Manycore Future
Architecting Solutions for the Manycore FutureArchitecting Solutions for the Manycore Future
Architecting Solutions for the Manycore Future
Talbott Crowell
 

More from Talbott Crowell (17)

Top 7 mistakes
Top 7 mistakesTop 7 mistakes
Top 7 mistakes
 
Top 3 Mistakes when Building
Top 3 Mistakes when BuildingTop 3 Mistakes when Building
Top 3 Mistakes when Building
 
Building high performance and scalable share point applications
Building high performance and scalable share point applicationsBuilding high performance and scalable share point applications
Building high performance and scalable share point applications
 
Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365
 
Custom Development for SharePoint
Custom Development for SharePointCustom Development for SharePoint
Custom Development for SharePoint
 
Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?
 
Developing a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint appDeveloping a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint app
 
Developing a provider hosted share point app
Developing a provider hosted share point appDeveloping a provider hosted share point app
Developing a provider hosted share point app
 
Introduction to F# 3.0
Introduction to F# 3.0Introduction to F# 3.0
Introduction to F# 3.0
 
PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012
 
PowerShell and SharePoint
PowerShell and SharePointPowerShell and SharePoint
PowerShell and SharePoint
 
Welcome to windows 8
Welcome to windows 8Welcome to windows 8
Welcome to windows 8
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePoint
 
SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010
 
Automating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePointAutomating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePoint
 
Introduction to F#
Introduction to F#Introduction to F#
Introduction to F#
 
Architecting Solutions for the Manycore Future
Architecting Solutions for the Manycore FutureArchitecting Solutions for the Manycore Future
Architecting Solutions for the Manycore Future
 

Recently uploaded

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

F# And Silverlight

  • 1. F# and Silverlight Talbott Crowell F# User Group, April 5, 2010http://fsug.org
  • 2. QuickIntro to F# Calculating Moving Average in F# Quick Intro to Silverlight Visualizing F# Using Silverlight Toolkit Agenda
  • 4. Functional language developed by Microsoft Research 2002 language design started by Don Syme 2005 F# 1.0.1 public release (integration w/ VS2003) 2010 F# is “productized” and baked into VS2010 Multi-paradigm Functional/Imperative/OO/Language Oriented Key characteristics Succinct, Type Inference (strongly typed), 1st class functions What is F#
  • 5. Type inferencing Strong typed Functions as values F# Intro b is a float let a = 5 let b = 6.0 let c = “7 feet” let d x = x * x let e = d b d is a function What data type is e?
  • 6. The |> Combinator “Pipe Forward” Example F# Combinators x |> f is the same as f x let sqr x = x * x sqr 5 5 |> sqr
  • 8. Start with a list of numbers Moving Average step 1 let testdata = [1.0 .. 10.0] testdata is a list of floats
  • 9. Create windows of the series Moving Average step 2 Seq.windowed 4 testdata it is a sequence of float arrays
  • 10. Average the values in each array Moving Average step 3 Array.average [|1.0; 2.0; 3.0; 4.0|]
  • 11. Use Seq.map to calculate average of all arrays in the sequence Moving Average step 4 let windowedData = Seq.windowed period data Seq.map Array.averagewindowedData the first argument is the function to apply to each item in the sequence the second argument is the sequence
  • 12. Use the pipe forward operator to put it together and omit the let Moving Average step 5 Seq.windowed period data |> Seq.map Array.average
  • 13. Put our algorithm into a function and test it Moving Average function let MovingAverage period data = Seq.windowed period data |> Seq.map Array.average let testdata = [1.0 .. 10.0] let test = MovingAverage 4 testdata
  • 14. Let’s generate some random data open System let GenerateData offset variance count = let rnd = new Random() let randomDouble variance = rnd.NextDouble() * variance let indexes = Seq.ofList [0..(count-1)] let genValuei = let value = float i + offset + randomDouble variance value Seq.map genValue indexes let dataGenerator = GenerateData 50.0 100.0 200
  • 15. Putting it together let data1 = List.ofSeqdataGenerator let data2 = List.ofSeq <| MovingAverage 10 data1
  • 17. Quick Intro to Silverlight
  • 18.
  • 19.
  • 20. Visual Studio 2008 Using Luke Hoban’s F# Silverlight templates Visual Studio 2010 RC Built-in F# Support for Silverlight in VS http://code.msdn.microsoft.com/fsharpsilverlight
  • 21. Silverlight Toolkit http://silverlight.codeplex.com/ Silverlight SDK Silverlight 3 SDK Silverlight 4 SDK Beta Graphing Controls
  • 22. Visualizing F# using Silverlight Toolkit
  • 23. Use the “Silverlight Application” template in Visual Studio Creates Silverlight Application (produces XAP) Creates Web Application (hosts web site and XAP) Create a Silverlight Application
  • 24. Initial UserControl Notice XML Namespaces (need to add more) XAML
  • 26. Add namespaces to XAML to support Silverlight Toolkit xmlns:controls="clr-namespace: System.Windows.Controls; assembly=System.Windows.Controls" xmlns:controlsToolkit="clr-namespace: System.Windows.Controls; assembly=System.Windows.Controls.Toolkit" xmlns:chartingToolkit="clr-namespace: System.Windows.Controls.DataVisualization.Charting; assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:chartingPrimitivesToolkit="clr-namespace: System.Windows.Controls.DataVisualization.Charting.Primitives; assembly=System.Windows.Controls.DataVisualization.Toolkit"
  • 27. Sample Series comes from Static Resource. Define Static Resource in App.xaml Add a chart to MainPage.xaml
  • 28. add namespace add sample dataset Static Resource App.xaml
  • 29. Similar to a Class Library project except it compiles with special options to target the Silverlight CLR Use file links to share F# files between Class Library and Silverlight Library Add Existing File Choose “Add As Link” from dropdown Create an F# Silverlight Library
  • 30. SeriesDataPoint is a class (type) that has two members, Index and Value Used for series data Add Chart Helper type SeriesDataPoint(index, value) = member this.Index with get() = index member this.Value with get() = value
  • 31. Used by XAML Designer to bind at design time Add Sample Data Set type SampleDataSet() = static member SampleSeries1 = let data = new ObjectCollection() data.Add(new SeriesDataPoint(0, 124.1)) data.Add(new SeriesDataPoint(1, 124.3)) data.Add(new SeriesDataPoint(2, 125.7)) data.Add(new SeriesDataPoint(3, 115.4)) data.Add(new SeriesDataPoint(4, 115.9)) data.Add(new SeriesDataPoint(5, 125.0)) data.Add(new SeriesDataPoint(6, 133.6)) data.Add(new SeriesDataPoint(7, 131.9)) data.Add(new SeriesDataPoint(8, 127.3)) data.Add(new SeriesDataPoint(9, 137.3)) data
  • 32. Designer is now binding with F#
  • 33. Code behind for MainPage.xaml Use constructor to wire up events Add code behind for MainPage public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); SilverlightEvents.RegisterHandlers(this.LayoutRoot); } }
  • 34. Event handling code for application in F# SilverlightEvents in F#
  • 35. Sample Button Click Event buttonGenerateSampleData.Click.Add(fun(_) -> let data = GenerateDataPoints 125.0 10.0 10 let series = DataConverter.ConvertDataPointsToLineSeries "Sample Series 3" data chart.Series.Add(series) )
  • 36. Slider Events - Mouse slider.MouseLeftButtonUp.Add(fun(_) -> model.UpdateSeries()) member internal this.UpdateSeries() = m_range <- (intslider.Value) let movingAverage = MovingAveragem_rangem_data let newSeries = this.GetMovingAverageSeriesmovingAverage chart.Series.[1] <- newSeries ()
  • 37. Slider Events – Value Changed slider.ValueChanged.Add(fun(callback) -> model.UpdateMovingAverage(callback)) member this.UpdateMovingAverage(args:RoutedPropertyChangedEventArgs<float>) = let oldVal = intargs.OldValue let newVal = intargs.NewValue if oldVal = newVal then () elif (Math.Abs(oldVal - newVal) > 4) then m_range <- newVal this.UpdateSeries() () else m_range <- newVal ()
  • 38. Generate Data and Moving Average
  • 39. Getting Started http://www.silverlight.net/getstarted/silverlight-4/ Tim Heuer’s Blog http://timheuer.com/blog/archive/2010/03/15/whats-new-in-silverlight-4-rc-mix10.aspx Silverlight 4 and Visual Studio 2010 RC
  • 40. Bart Czernicki’s Silverlight Hack Blog http://www.silverlighthack.com/post/2009/11/04/Silverlight-3-and-FSharp-Support-in-Visual-Studio-2010.aspx Luke Hoban’s WebLog http://blogs.msdn.com/lukeh/archive/2009/06/26/f-in-silverlight.aspx support for F# in VS 2008 http://code.msdn.microsoft.com/fsharpsilverlight F# and Silverlight 2.0 http://jyliao.blogspot.com/2008/11/f-and-silverlight-20.html Other Helpful Links
  • 41. http://fsug.org Thank you. Questions?F# and Silverlight Talbott Crowell ThirdM.com http://talbottc.spaces.live.com Twitter: @talbottand @fsug