Skip to content

Instantly share code, notes, and snippets.

View adamnemecek's full-sized avatar

adamnemecek

View GitHub Profile
abstract class Dual(val rank: Int) {
self =>
// Cell value accessor
protected def get(r: Int, c: Int): Double
// Memoizing cell value accessor
def apply(r: Int, c: Int): Double = memo.getOrElseUpdate(r - c, self.get(r, c))
// The memo table
@adamnemecek
adamnemecek / OpenStarSemiring.lhs
Created March 2, 2024 04:37 — forked from sjoerdvisscher/OpenStarSemiring.lhs
Playing with 'A Very General Method of Computing Shortest Paths'
This is an extension of "A Very General Method of Computing Shortest Paths" to use "open matrices".
This is from a paper "The Open Algebraic Path Problem" by Jade Master https://arxiv.org/abs/2005.06682
> {-# LANGUAGE TypeFamilies #-}
> {-# LANGUAGE TypeApplications #-}
> {-# LANGUAGE FlexibleContexts #-}
> {-# LANGUAGE StandaloneDeriving #-}
> {-# LANGUAGE AllowAmbiguousTypes #-}
> {-# LANGUAGE ScopedTypeVariables #-}
> module OpenStarSemiring where
@adamnemecek
adamnemecek / definition_of_truth.md
Created August 23, 2022 18:58 — forked from Mec-iS/definition_of_truth.md
Truth as Eigenform

Definition of Truth

Jason the Goodman <[email protected]>:

How about defining "truth" with "stability" of the coupling loop between "the object" and the cognitive system coupling with the "object"? If the process stabilizes and an eigenvalue of the loop emerges, we say "a truth" is found. This would refocus our attention from the "object" itself to the nature of the cognitive system, which may include animals and robots in addition to humans. My tentative way to upgrade from first-order thinking to the second-order thinking. Then, instead of searching for "truth", we search for the "Lyapunov potential function" for the situation if we could find one...

Louis H Kauffman <[email protected]>

Eigenform is important way to formalize a kind of stability. Truth is a special kind of eigenform, not just any eigenform. Truth means the truth of a PROPOSITION about something. So we need to have a language involved and the notion that the propositions are talking about some domain where it is possible to c

@adamnemecek
adamnemecek / programming-as-theory-building.md
Created June 1, 2020 03:25 — forked from onlurking/programming-as-theory-building.md
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@adamnemecek
adamnemecek / gist:ae2755c5c4eaabd0d864e6c62dbe5088
Created November 28, 2019 21:10 — forked from LearnCocos2D/gist:77f0ced228292676689f
Overview of Entity Component System (ECS) variations with pseudo-code

For background and further references see: Entity Component Systems on Wikipedia

ECS by Scott Bilas (GDC 2002)

Entity->Components->Update
  • entity = class: no logic + no data OR at most small set of frequently used data (ie position)
  • component = class: logic + data
foreach entity in allEntities do
    foreach component in entity.components do
@adamnemecek
adamnemecek / Clifford.hs
Created March 29, 2019 16:55 — forked from fkuehnel/Clifford.hs
Haskell module for Clifford Algebra tensor representations, and a Geometric Algebra module utilizing the tensor representation
-- credit goes to sigfpe
{-# LANGUAGE MultiParamTypeClasses
,TemplateHaskell
,GeneralizedNewtypeDeriving
,DeriveFunctor
,FunctionalDependencies
,FlexibleInstances
,UndecidableInstances
,FlexibleContexts
,Rank2Types #-}
@adamnemecek
adamnemecek / BikeNode.swift
Created April 4, 2018 18:07 — forked from lachlanhurst/BikeNode.swift
Poorly written extract of source code used to create SceneKit 'bike dude'. Video here https://www.youtube.com/watch?v=UYwLltzNu_w
//
// MIT License
// Copyright (c) 2017 Lachlan Hurst
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@adamnemecek
adamnemecek / ml_resources.md
Created January 3, 2017 18:52 — forked from vaibhaw/ml_resources.md
Machine Learning Resources

Courses

enum Sharp: Int { case C = 0, G, D, A, E, B, F }
func sKeyForNote(n: Sharp) -> [Sharp] {
return (0..<n.rawValue)
.map{ n in (n + 6) % 7 }
.flatMap(Sharp.init)
}
enum Flat: Int { case F = 1, B, E, A, D, G }
enum Expr {
case Lit(Int)
indirect case Neg(Expr)
indirect case Add(Expr,Expr)
indirect case Mul(Expr,Expr)
indirect case Sub(Expr,Expr)
}
let spaces = many(oneof(" \n\r"))
func token<P: ParserType>(p: P) -> Parser<P.A> {