Skip to content

Instantly share code, notes, and snippets.

import Mathlib.Tactic
import Mathlib.Data.Real.Basic
import Mathlib.Data.Vector.Zip
theorem reverse_get_kth (n: Nat) (k: Fin n) (v: Vector Nat n):
v.get k = v.reverse.get (Fin.revPerm k) := by
cases n with
| zero => exact k.elim0
| succ =>
using System;
using System.Text;
namespace ConsoleApp6
{
class Program
{
static void Main(string[] args)
{
while (true)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<gcServer enabled="true"/>
</runtime>
</configuration>
@daxfohl
daxfohl / AlgorithmW.fs
Last active February 27, 2019 07:10 — forked from praeclarum/AlgorithmW.fs
Algorithm W - or Hindley-Milner polymorphic type inference - in F#
module AlgorithmW
// HINDLEY-MILNER TYPE INFERENCE
// Based on http://catamorph.de/documents/AlgorithmW.pdf
type Lit =
| LInt of int
| LBool of bool
type Exp =
@daxfohl
daxfohl / Program.fs
Last active May 16, 2020 01:15
Simple SOA in F#
module Program
// A simple service
module PrinterService =
open System
// Helper functions first
// They can be public for easy unit testing, so long as they don't leave things inconsistent
let isObscene s = String.length s = 4
@daxfohl
daxfohl / addChild.fs
Last active October 10, 2020 08:34
let addChild updateNode addNode value parent =
match withNewChild value parent with
| None -> async.Return None
| Some (newParent, child) as path ->
async { do! addNode child
do! updateNode newParent
return Some child }
let addChildById getNode updateNode addNode logAction value parentId =
async { let! parent = getNode parentId
{-# LANGUAGE MultiParamTypeClasses #-}
module DataLib where
class Record a where
getId :: a -> Int
insert :: Record a => a -> [a] -> [a]
insert r rs = r : rs
@daxfohl
daxfohl / updates.txt
Last active November 7, 2016 02:48
API updates
A few general notes:
* We switched from Mongo to Postgres, so all the lookups are ID based rather than filename/foldername based.
* There's a new table "photo_sequence". The hierarchy is "folder 1->* photo_sequence 1->* upload", where a "sequence" denotes e.g. one run through the gif sequence, and the corresponding "uploads" are each of the individual phots, gifs, user-edits, etc from that sequence.
* Folders can contain multiple "galleries", each of which has its own sharing configuration. A common use case is in printer mode, they'll have one gallery for the individual shots allowing social, and one for the composites just allowing prints, and run two separate tablets.
* The workflow for customizing images and forms has been improved, allowing things like gif annotation without custom code.
* I denote an array of objects below by brackets, e.g. [string] is a string array or [{id:int;name:string}] is an array of that record type.
* ... means there are other fields you can ignore
* v4 api serv
package com.company;
import java.util.ArrayDeque;
import java.util.PriorityQueue;
import java.util.Queue;
public class Main {
// Start by defining Nodes and Edges (Nodes in a tree have Edges of a certain length to a child Node)
static class Edge {
@daxfohl
daxfohl / x.fs
Last active August 12, 2016 15:25
open System.Threading.Tasks
open System.Threading
open System
let criteria _ b = b = 10
let callback (i: int) =
Thread.Sleep(50)
printfn "Callback %d" i
let rec compute (task: Task) state =