MARK P. JONES
Pacific Software Research Center
Department of Computer Science and Engineering
Oregon Graduate Institute of Science and Technology
Every once in a while I am faced with someone who denies that the rational numbers (or fractions, or pairs of integers) can be put into a bijective correspondence with natural numbers. To deal with the situation, I coded up the bijection. So now I can just say: "Really? Interesting. Please provide a pair of numbers (i,j)
which is not enumerated by f
, as defined in my gist." I am still waiting for a valid counter-example.
Anyhow, here is a demo of f
and g
at work. I am using the Python version, but a Haskell variant is included as well.
The 100-th pair is:
>>> f(100)
(10, 4)
{-# LANGUAGE DataKinds, TemplateHaskell, TypeFamilies, QuasiQuotes #-} | |
import TICTACTOE | |
game :: ([tq| x o x | |
o o x | |
☐ ☐ x |]) | |
game = (?) |
[alias] | |
l = log -10 --pretty=tformat:'%C(yellow)%ad %Cred%h%C(bold blue)%d%Creset %s' --date=short | |
l2 = log -10 --pretty=tformat:'%C(yellow)%ad %Cred%h%C(bold blue)%d%Creset %s %Cgreen(%an)%Creset' --date=short | |
l3 = log -10 --pretty=tformat:'%Cred%h%C(bold blue)%d%Creset %s %C(yellow)%cr %Cgreen%an%Creset' --date=relative | |
l4 = log -10 --pretty=tformat:'%Cred%h %C(yellow)%ad %Cgreen%an%C(bold blue)%d %Creset%s' --date=short | |
lg = log -10 --graph --pretty=tformat:'%C(yellow)%ad %Cred%h%C(bold blue)%d%Creset %s' --date=short | |
lg2 = log -10 --graph --pretty=tformat:'%C(yellow)%ad %Cred%h%C(bold blue)%d%Creset %s %Cgreen(%an)%Creset' --date=short | |
lg3 = log -10 --graph --pretty=tformat:'%Cred%h%C(bold blue)%d%Creset %s %C(yellow)%cr %Cgreen%an%Creset' --date=relative | |
lg4 = log -10 --graph --pretty=tformat:'%Cred%h %C(yellow)%ad %Cgreen%an%C(bold blue)%d %Creset%s' --date=short | |
s = status -sb |
#!/bin/sh | |
inPreprocessorMode () { | |
hasE=0 | |
hasU=0 | |
hasT=0 | |
for arg in "$@" | |
do | |
if [ 'x-E' = "x$arg" ]; then hasE=1; fi | |
if [ 'x-undef' = "x$arg" ]; then hasU=1; fi |
just use GHC for OSX https://ghcformacosx.github.io
the rest of these directions are preserved for historical purposes
xcode-select --install ; brew tap homebrew/versions ; brew tap homebrew/dupes \
-- | Simple in-process key/value cache | |
-- | |
-- Of course, for really simple stuff you could probably use unsafeInterleaveIO | |
module Cache (Cache, newCache, fromCache) where | |
import Control.Monad (void) | |
-- Could also use STM instead | |
import Control.Concurrent (forkIO, Chan, newChan, readChan, writeChan, MVar, newEmptyMVar, putMVar, takeMVar) |
{-# Language GeneralizedNewtypeDeriving #-} | |
{-# Language OverloadedStrings #-} | |
import Data.Monoid | |
import Text.Blaze.Html.Renderer.Text | |
import qualified Text.Blaze.Html5 as H | |
import qualified Text.Blaze.Html5.Attributes as A | |
import Text.Blaze.Html ((!), Html) | |
import Control.Monad.Writer | |
import Control.Monad.Identity |