Skip to content

Instantly share code, notes, and snippets.

View AviAvni's full-sized avatar

Avi Avni AviAvni

View GitHub Profile
#I __SOURCE_DIRECTORY__
#r @"bin/Debug/EvalWrapper.dll"
open Microsoft.MSR.CNTK.Extensibility.Managed
open System.Drawing
open System.Collections.Generic
open System
let createModel modelPath =
let model = new IEvaluateModelManagedF()

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@mrange
mrange / ADT.tt
Last active May 24, 2016 21:16
Reusable ADT generator for C#/T4
<#
var model = new Model ()
{
Namespace = "MyNameSpace" ,
Unions = new []
{
U ( "CustomerKind"
, UC ("Person" , F ("string", "FullName"), F ("string", "SocialNo" ), F ("DateTime", "BirthDate" ))
, UC ("Company", F ("string", "Name" ), F ("string", "CompanyNo"), F ("string" , "TaxNo" ))
),
type Next<'T> =
| Done of 'T
| Jump of Trampoline<'T>
and Trampoline<'T> = unit -> Next<'T>
module Trampoline =
let Return v : Trampoline<'T> =
fun () ->
Done v
#time
let inline sum list =
match list with
| [] -> LanguagePrimitives.GenericZero< 'T >
| t ->
let mutable acc = LanguagePrimitives.GenericZero< 'T >
for x in t do
acc <- Checked.(+) acc x
acc
@bishboria
bishboria / springer-free-maths-books.md
Last active May 27, 2026 13:01
Springer made a bunch of books available for free, these were the direct links
/// <summary>
/// Stops keystrokes on a WPF Window or Adornment from propagating to the Visual Studio code editor.
///
/// "The reason that keys like Backspace and Delete do not work in your WPF windows/Adornments is due to Visual Studio's usage of IOleComponentManager and IOleComponent.
/// Visual Studio and WinForms both use IOleComponent as a way of tracking the active component in the application.
///
/// WPF does not implement IOleComponent or use the IOleComponentManager for its windows. This means that when your WPF window is active, Visual Studio doesn't know that its
/// primary component should not be processing command keybindings. Since "Backspace", "Delete", and several other keys are bound to commands for the text editor,
/// Visual Studio continues processing those keystrokes as command bindings."
///
@bryanedds
bryanedds / Vsync.fs
Last active October 24, 2016 21:32
The 'Vsync' (AKA, 'Variable Synchronization') computation expression that coheres into the Sync comp. expr. when SYNC is #defined, and into the Async comp. expr. otherwise.
namespace YourNamespaceHere
open System
open System.Diagnostics
open System.Threading
open System.Threading.Tasks
/// The 'Sync' builder for evaluating expressions in a synchronous style to aid debugging.
type [<Sealed>] Sync () =
member inline this.Bind (x, f) = f x
member inline this.Return x = x
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, TemplateHaskell, FlexibleInstances #-}
{-# OPTIONS_GHC -Wall -fno-warn-missing-signatures #-}
module QQAST where
import Control.Applicative
import Control.Exception
import Control.Monad.State
import Data.Data (Data)
import Data.Generics (extQ)
import Data.IORef