Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FlexibleContexts #-}
-- QReg type class and instances
class QReg a where
mapIndices :: a -> (Int -> Int) -> a
indices :: a -> [Int]
data Qubit = Qubit { index :: Int } deriving (Eq, Show)
instance QReg Qubit where
// QReg interface and implementations
interface QReg<T : QReg<T>> {
fun mapIndices(mapper: (Int) -> Int): T
fun indices(): List<Int>
}
data class Qubit(val index: Int) : QReg<Qubit> {
override fun mapIndices(mapper: (Int) -> Int) = Qubit(mapper(index))
override fun indices() = listOf(index)
Installing collected packages: sortedcontainers, pytz, ply, mpmath, wrapt, urllib3, tzdata, typing_extensions, types-protobuf, types-deprecated, tqdm, toolz, tomli, sympy, sniffio, six, ruamel.yaml.clib, pyzmq, python-rapidjson, pyparsing, pyasn1, psutil, protobuf, pillow, packaging, ordered-set, opt_einsum, numpy, networkx, mypy_extensions, msgpack, llvmlite, kiwisolver, idna, h11, grpcio, fonttools, exceptiongroup, duet, cython, cycler, charset-normalizer, certifi, cachetools, autoray, attrs, types-requests, typedunits, scipy, ruamel.yaml, rsa, requests, quil, python-dateutil, pylatex, pyasn1-modules, proto-plus, numba, mypy, httpcore, grpc-interceptor, googleapis-common-protos, deprecated, cytoolz, cotengra, contourpy, anyio, rpcq, quimb, pandas, matplotlib, httpx, grpcio-status, google-auth, qcs-api-client-common, google-api-core, qcs-sdk-python, pyquil
Successfully installed anyio-4.9.0 attrs-25.3.0 autoray-0.7.1 cachetools-5.5.2 certifi-2025.4.26 charset-normalizer-3.4.2 contourpy-1.3.2 cotengra-0.7.2 c
@daxfohl
daxfohl / quantum.kt
Last active January 13, 2025 19:50
quantum.kt
class Tableau {}
class SV {}
class DM {}
class Stabilizer {}
class Unitary {}
class Channel {}
fun apply(stabilizer: Stabilizer, tableau: Tableau) {}
fun apply(unitary: Unitary, sv: SV) {}
fun apply(channel: Channel, dm: DM) {}
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