Skip to content

Instantly share code, notes, and snippets.

View bjartwolf's full-sized avatar

Bjørn Einar Bjartnes bjartwolf

View GitHub Profile
@bjartwolf
bjartwolf / 2.5.2.fs
Created April 21, 2014 18:41
2.5.2.fs
let VolumeNoHeightis0(a:decimal<m>) =
(a <= 10000000000m<m> && a >= 0m<m>) ==>
(lazy (V 0m<m> a a = 0m<m^3>))
Check.Quick VolumeNoHeightis0
open System
open System.IO
open FsCheck
open FsCheck.Xunit
[<Measure>] type m
[<Measure>] type Area = m^2
[<Measure>] type Volume = Area*m
let f (h:decimal<m>) = h
[<Measure>] type m
[<Measure>] type s
[<Measure>] type kg
[<Measure>] type N = kg m / s / s
let a = 9.81<m/s/s>
let mass = 10.0<kg>
let f = a*mass
let pow3 (x:float<'u>):float<'u^3> =
let power = pown (float x) 3
@bjartwolf
bjartwolf / 1e.s
Last active August 29, 2015 13:59
[<Measure>] type Length
[<Measure>] type Area = Length*Length
let area (a : float<Length>) (b: float<Length>) = System.Math.PI*a*b
let a1:float<Area> = area 0.0<Length> 1.0<Length>
let a2:float<Area> = area 1.0<Length> 0.0<Length>
let a3:float<Area> = area 1.0<Length> 1.0<Length>
("for 0,1: " + a1.ToString()).Dump()
("for 1,0: " + a2.ToString()).Dump()
("for 1,1, circle should be pi: " + a3.ToString()).Dump()
@bjartwolf
bjartwolf / 1d.fs
Last active August 29, 2015 13:59
[<Measure>] type Length
[<Measure>] type Area = Length*Length
let area (a : float<Length>) (b: float<Length>) = 2.0*a*b
let a1:float<Area> = area 0.0<Length> 1.0<Length>
let a2:float<Area> = area 1.0<Length> 0.0<Length>
let a3:float<Area> = area 1.0<Length> 1.0<Length>
("for 0,1: " + a1.ToString()).Dump()
("for 1,0: " + a2.ToString()).Dump()
("for 1,1, circle should be pi: " + a3.ToString()).Dump()
[<Measure>] type Length
[<Measure>] type Area = Length*Length
let area (a : float<Length>) (b: float<Length>) = a * a *a / b
let a1:float<Area> = area 0.0<Length> 1.0<Length>
let a2:float<Area> = area 1.0<Length> 0.0<Length>
("for 0,1: " + a1.ToString()).Dump()
("for 1,0: " + a2.ToString()).Dump()
@bjartwolf
bjartwolf / 1b.fs
Created April 11, 2014 22:20
1b.fs
[<Measure>] type Length
[<Measure>] type Area = Length*Length
let area (a : float<Length>) (b: float<Length>) = a * a + b * b
let a1:float<Area> = area 0.0<Length> 1.0<Length>
a1.Dump()
@bjartwolf
bjartwolf / 1a.fs
Last active August 29, 2015 13:59
streetfight1a
[<Measure>] type Length
[<Measure>] type Area = Length*Length
let area (b : float<Length>) (a: float<Length>) = a*b^2
let a1:float<Area> = area 3.0<Length> 5.0<Length>
[Route("")]
public HttpResponseMessage GetResult()
{
var fs = new FileStream(@"C:\data\medline13n0701.xml"), FileMode.Open);
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(fs)
};
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xml");
return response;
@bjartwolf
bjartwolf / turtle.py
Created January 23, 2014 15:01
turtle.py
from turtle import *
shape("turtle")
for count in range(4):
forward(100)
right(90)