Instantly share code, notes, and snippets.

# Gatlin Johnsongatlin

• Sort options
Created Oct 14, 2012
Simulation of Operational Transformation with Cloud Haskell
 {- This is a simple simulation of OT with Cloud in which all slaves generate and apply random operations. It should work in theory. In practice, however I wasn't apply to test it because my installation of distributed-process is apparently broken. Specifically, `spawn` doesn't seem to work (I tested it with some examples from the Well-Typed blog). This code depends on https://github.com/timjb/haskell-operational-transformation. -}
Created Apr 24, 2012
View factor.hs
 npto :: (Integral a) => a -> [a] npto x = [2,3] ++ concat [[x*6-1,x*6+1] | x <- [1..n]] where n = ((+1) . round . sqrt . fromIntegral \$ x) `div` 6 factors :: (Integral a) => a -> [a] factors 1 = [] factors x = least : factors (x `div` least) where least = head \$ fs ++ [x] fs = filter ((==0) . mod x) . npto \$ x
Created Feb 22, 2012
Long-winded linearly typed variables
View linearly-typed.pl
 #!/usr/bin/env perl use strict; use warnings; use Data::Dump; use Data::Alias "alias"; use Scalar::Util qw(weaken isweak); my \$foo = ["a".."z"]; alias my @bar = @\$foo;
Created Feb 11, 2012
Game of Life in 131 characters of Perl.
View gist:1803656
 #!perl use strict; # Accepts a grid size, and a list representing the grid. 131 # characters. RUNS UNDER STRICTURES BABY YEAH. my\$life=sub{\$a=shift;map{\$b=\$_[\$_];my\$n;\$n+=\$_[\$_]for(\$_-\$a-1..\$_-\$a+1,\$_-1,\$_+1,\$_+\$a-1..\$_+\$a+1);\$n+\$b==3||\$b&&\$n==4||0}0..\$#_}; my \$result = join '', \$life->( 5, qw/
Created Jun 26, 2010