This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Net; | |
namespace DashboardApp | |
{ | |
public static class Yahoo | |
{ | |
public static IEnumerable<object> GetPrices(string stock) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start in VS: View -> Other Windows -> F# Interactive | |
open System | |
// Turn on timing in F# interactive | |
#time | |
// Performance bottle kneck | |
let formatKey (a:string,b:string) = | |
String.Format("{0}:{1}", a, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Result = Success | Failure | Running | |
type Behavior = | |
| Action of (unit -> Result) | |
| Selector of Behavior list | |
| Sequence of Behavior list | |
let rec behave = function | |
| Action f -> f () | |
| Selector xs -> select xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type abbreviations | |
type label = string | |
type identifier = string | |
type index = int | |
type HashTable<'k,'v> = System.Collections.Generic.Dictionary<'k,'v> | |
/// Small Basic arithmetic operation | |
type arithmetic = Add | Subtract | Multiply | Divide | |
/// Small Basic comparison operaton | |
type comparison = Eq | Ne | Lt | Gt | Le | Ge | |
/// Small Basic logical operation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ``Foq cannot explicitly return an F# type as null`` | |
open System | |
open Foq | |
// Discriminated Unions | |
type TimeInForce = GoodTillCancel | GoodTillDate of DateTime | |
type IOrder = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: As a writer I like to use bullet points | |
Scenario: Writing lists with bullets | |
Given a list of bullet points: | |
* 1,2 | |
* 2,3 | |
* 3,4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Processing style vector type | |
/// See http://processing.org/reference/PVector.html | |
type PVector(x:float,y:float) = | |
new(x:int,y:int) = PVector(float x,float y) | |
member val X = x with get,set | |
member val Y = y with get,set | |
member vector.Mag() : float = | |
sqrt(x * x + y * y) | |
member vector.Normalize() : unit = | |
let length = vector.Mag() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<AutoOpen>] | |
module Utils = | |
/// Generate a random integer within [a, b] | |
let randomInt = | |
let rand = System.Random() | |
fun (a,b) -> a + rand.Next(b-a+1) | |
type Action = Left = 0 | Right = 1 | Up = 2 | Down = 3 | |
type Program(numStates, numSymbols, mapWidth, mapHeight) = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "System.Windows.dll" | |
#r "Tsunami.IDESilverlight.dll" | |
#r "Telerik.Windows.Controls.dll" | |
#r "Telerik.Windows.Controls.Docking.dll" | |
#r "Telerik.Windows.Controls.Navigation.dll" | |
open System | |
open System.Windows | |
open System.Windows.Controls | |
open System.Windows.Media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
open System.Text | |
open System.Xml | |
open System.Web | |
open FSharp.Data | |
open HtmlAgilityPack | |
let parse prefix (doc:XmlDocument) = | |
let content = | |
doc.GetElementsByTagName("div") |