Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Burge MichaelBurge

View GitHub Profile
@MichaelBurge
MichaelBurge / gist:3de86bc227bff32ac9d15b162c6c6da7
Created Jun 19, 2018
StackLisp implementation of Pyramid runtime
View gist:3de86bc227bff32ac9d15b162c6c6da7
#lang sweet-exp stacklisp
provide
rename-out void identity
define-variable!
set-variable-value!
lookup-variable-value
extend-environment
tag
rename-out allocate-words allocate
@MichaelBurge
MichaelBurge / fitpoly.hs
Created Mar 21, 2018
First Haskell I ever wrote
View fitpoly.hs
import System( getArgs )
import System.Console.GetOpt
import System.IO
import Ratio
import Numeric
{- Returns the binomial coefficient. -}
binomial m 0 = 1
binomial 0 n = 0
binomial (m+1) (n+1) = (binomial m n) * (m+1) `div` (n+1)
@MichaelBurge
MichaelBurge / gist:237217e3151f2788f3c04c1c5ded4f4c
Created Mar 21, 2018
Old "enterprise" integer operations in C++
View gist:237217e3151f2788f3c04c1c5ded4f4c
#include <iostream>
#include <deque>
#include <functional>
#include <string>
#include <list>
#include <algorithm>
using namespace std;
union Integer;
View gist:1cc8e45ac021729c133fd42155a6284f
import System.IO.Temp
import System.IO.Unsafe
import System.Process
import Data.Text
debugDiffIO :: Show a => a -> a -> IO (Maybe Text)
debugDiffIO x y = do
xf <- writeSystemTempFile "x" $ show x
yf <- writeSystemTempFile "y" $ show y
(exitCode, result, _) <- readProcessWithExitCode "git" ["diff", "--no-index", "--color-words=.", xf, yf] ""
View gist:3462043f6252826845d36731cc3d99cd
f x = if even x then x `div` 2 else reduce (3 * x + 1) where reduce x | even x = reduce $ x `div` 2 ; reduce x = x
until (\x -> f x == x) f 19
1
You can’t perform that action at this time.