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
let btnUp = new Button("Increment", Visible=true) | |
let btnDown = new Button("Decrement", Visible=true) | |
let lbl = new Label(Text=" Count: 0", Visible=true) | |
Event.merge | |
(btnUp.Clicked |> Event.map (fun _ -> +1)) | |
(btnDown.Clicked |> Event.map (fun _ -> -1)) | |
|> Event.scan (+) 0 | |
|> Event.map (sprintf " Count: %d") | |
|> Event.add (fun s -> lbl.Text <- s) |
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 "ServiceStack.Text.dll" | |
open System.Net | |
open System.IO | |
open ServiceStack.Text | |
type System.Net.WebRequest with | |
member x.GetResponseAsync() = | |
Async.FromBeginEnd(x.BeginGetResponse, x.EndGetResponse) | |
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
(* Stand-alone HelloWorld ServiceStack Web Service with F# on Mono/Windows using HttpListener | |
INFO: and C#/ASP.NET HelloWorld example at: http://servicestack.net/ServiceStack.Hello/ | |
Instructions: | |
1) download https://github.com/ServiceStack/ServiceStack/downloads | |
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll FSharpStack.fs | |
3) sudo mono FSharpStack.exe | |
*) | |
open System |
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
(* Stand-alone Twitter API ServiceStack Web Service with F# on Mono/Windows using HttpListener | |
Instructions: | |
1) download https://github.com/ServiceStack/ServiceStack/downloads | |
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll FTweetStack.fs | |
3) sudo mono FTweetStack.exe | |
*) | |
open System | |
open System.IO |
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
let taxOf salary taxRates = | |
((0m,0)::taxRates, taxRates) | |
||> Seq.zip | |
|> Seq.map(fun ((_, prevBand),(rate, band)) -> (prevBand, rate, band)) | |
|> Seq.sumBy(fun (prevBand, rate, band) -> | |
match salary with | |
| x when x < prevBand -> 0m | |
| x when x > band -> decimal(band - prevBand) * rate | |
| x -> decimal(x - prevBand) * rate | |
) |
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; | |
namespace FastIsraelTaxCalculator | |
{ | |
class MainClass | |
{ | |
static readonly string[] DefaultAmounts = new[] { "5000", "5800", "9000", "15000", "50000" }; | |
public static void Main (string[] args) | |
{ |
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
(* Stand-alone Twitter API ServiceStack Web Service with F# on Mono/OSX hosted by HttpListener | |
Instructions: | |
1) download https://github.com/ServiceStack/ServiceStack/downloads | |
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll FTweetStack.fs | |
3) sudo mono FTweetStack.exe | |
*) | |
open System | |
open ServiceStack.ServiceHost |
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
(* http://www.simontylercousins.netsolution to http://ayende.com/blog/108545/the-tax-calculation-challenge *) | |
let taxes salary = | |
let rates = [ | |
40230.0m,0.45m; | |
21240.0m,0.33m; | |
14070.0m,0.3m; | |
8660.0m,0.23m; | |
5070.0m,0.14m; | |
0.0m,0.1m] |
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
(* Stand-alone Hello World ServiceStack Web Service with F# on Mono/OSX hosted by HttpListener | |
Instructions: | |
1) download https://github.com/ServiceStack/ServiceStack/downloads | |
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll Hello.fs | |
3) sudo mono Hello.exe | |
Read More: For the benefits of a ServiceStack Hello World Service see: http://www.servicestack.net/ServiceStack.Hello/ | |
*) |
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
<%@ Application Inherits="HelloFSharp.Global" %> |