Instantly share code, notes, and snippets.

# giuliohome

• Sort options
Created Feb 18, 2019
 import Database.HDBC import Database.HDBC.ODBC data Person = Person { id :: Int , name :: [Char] } deriving Show convRow :: [SqlValue] -> Person convRow [sqlId, sqlDesc] =
Created Feb 9, 2019 — forked from pervognsen/clifford.md
View clifford.md

A quadratic space is a real vector space V with a quadratic form Q(x), e.g. V = R^n with Q as the squared length. The Clifford algebra Cl(V) of a quadratic space is the associative algebra that contains V and satisfies x^2 = Q(x) for all x in V. We're imposing by fiat that the square of a vector should be the quadratic form's value and seeing where it takes us. Treat x^2 = Q(x) as a symbolic rewriting rule that lets you replace x^2 or x x with Q(x) and vice versa whenever x is a vector. Beyond that Cl(V) satisfies the standard axioms of an algebra: it lets you multiply by scalars, it's associative and distributive, but not necessarily commutative.

Remarkably, this is all you need to derive everything about Clifford algebras.

Let me show you how easy it is to bootstrap the theory from nothing.

We know Cl(V) contains a copy of V. Since x^2 = Q(x) for all x, it must also contain a copy of some nonnegative reals.

Created Nov 2, 2018
Calling C# from JavaScript
View PageAjax2.aspx
 protected async void Page_Load(object sender, EventArgs e) { test++; if (!Page.IsPostBack) { if (Request.Form["method"] == "Test") { MyType[] obj = await Test(Request.Form["msg1"], Request.Form["msg2"]); string json = new JavaScriptSerializer().Serialize(obj); Response.Write(json);
Last active Aug 18, 2018
F# port of John A De Goes "FP to the max"
View FP2TheMax.fs
 open System type Eff<'Ctx, 'T> = 'Ctx -> 'T type EffBuilder() = member __.Return x : Eff<'Ctx,'T> = fun _ -> x member __.Bind(f : Eff<'Ctx, 'T>, g : 'T -> Eff<'Ctx, 'S>) : Eff<'Ctx, 'S> = fun c -> g (f c) c member __.Zero() : Eff<'Ctx, unit> =
Created Aug 9, 2018
more robust check
View safetraversal.fs
 let rec bfs2robust (fanout: Map<'node, 'node seq> -> 'node -> 'node seq) (tree: Map<'node, 'node seq>) (node: 'node) : 'node seq = let single = seq [node] match fanout tree node with | e when e = Seq.empty -> single | s -> Seq.fold (fun acc item -> bfs2robust fanout (tree |> Map.remove node) item |> Seq.append acc) single s |> Seq.distinct
Last active Aug 9, 2018
View gotrees.fs
 let rec bfs2 (fanout: Map<'node, 'node seq> -> 'node -> 'node seq) (tree: Map<'node, 'node seq>) (node: 'node) : 'node seq = let single = seq [node] match fanout tree node with | e when e = Seq.empty -> single | s -> Seq.fold (fun acc item -> bfs2 fanout tree item |> Seq.append acc) single s
Created Aug 7, 2018
TextBloacks with colours !!!
View BindableTextBlock.cs
 public class BindableTextBlock : TextBlock { public ObservableCollection InlineList { get { return (ObservableCollection)GetValue(InlineListProperty); } set { SetValue(InlineListProperty, value); } } public static readonly DependencyProperty InlineListProperty = DependencyProperty.Register("InlineList", typeof(ObservableCollection), typeof(BindableTextBlock), new UIPropertyMetadata(null, OnPropertyChanged));
Created Aug 2, 2018
View view_v2.xaml

Created Aug 2, 2018
Model with composition
View model_v2.fs
 type Back2UI() = inherit SimpleViewModelBase() let mutable _msg = "" member this.msg with get() = _msg and set value = _msg <- value this.OnPropertyChanged(<@ this.msg @>) type ActivePassive = Active | Passive
Created Aug 2, 2018
UI binding from an array to a datagrid
View view.xaml

You can’t perform that action at this time.