Skip to content

Instantly share code, notes, and snippets.

@gatlin
gatlin / mymap.pl
Created Dec 26, 2011
Functional definition of map in Perl
View mymap.pl
#!/usr/bin/env perl
use strict;
use warnings;
sub myMap (&@) {
my ($fn, @lst) = @_;
return () unless @lst;
return (sub { local $_=$_[0];$_[1]->() }->($lst[0],$fn),
&myMap( $fn, @lst[1..$#lst] ));
@gatlin
gatlin / sat.hs
Created Feb 6, 2012
SAT Solver in Haskell
View sat.hs
-- This is going to be on Hackage soon! https://github.com/gatlin/surely
{-# LANGUAGE BangPatterns #-}
-- |
-- Module : AI.Surely
-- Copyright : 2012 Gatlin Johnson
-- License : LGPL 3.0
-- Maintainer : rokenrol@gmail.com
-- Stability : experimental
@gatlin
gatlin / lexical.pl
Created Jun 27, 2012
Extremely basic example of lexical scope use in Perl
View lexical.pl
#!/usr/bin/env perl
use v5.16;
use strict;
use warnings;
sub c {
my $lexicalValue = 0;
return sub {
say $lexicalValue;
@gatlin
gatlin / hello.ll
Created Jul 6, 2012
LLVM output of a simple Haskell program
View hello.ll
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin10.0.0"
declare ccc i8* @memcpy(i8*, i8*, i64)
declare ccc i8* @memmove(i8*, i8*, i64)
declare ccc i8* @memset(i8*, i64, i64)
declare ccc i64 @newSpark(i8*, i8*)
%__stginit_Main_struct = type <{}>
@__stginit_Main = global %__stginit_Main_struct<{}>
%sfT_srt_struct = type <{i64}>
@gatlin
gatlin / hello.hs
Created Jul 6, 2012
Simple Haskell program
View hello.hs
module Main where
main = do
putStrLn $ "Hello, World!"
@gatlin
gatlin / hello.js
Created Jul 6, 2012
Emscripten output for a simple Haskell program
View hello.js
// Note: Some Emscripten settings will significantly limit the speed of the generated code.
// Note: Some Emscripten settings may limit the speed of the generated code.
// TODO: " u s e s t r i c t ";
try {
this['Module'] = Module;
} catch(e) {
this['Module'] = Module = {};
}
@gatlin
gatlin / degree.pl
Created Jul 29, 2012
Simple regex for DMS angle notation
View degree.pl
#!/usr/bin/env perl
use v5.16;
use strict;
use warnings;
while (my $str = <STDIN>) {
say "DMS" if $str =~
m/([0-9]+(\W*)deg((ree)?s?)?)?(\W*)([0-9]+(\W*)min((ute)?s?)?)?(\W*)([0-9]+(\.[0-9]*)?(\W*)sec((ond)?s?)?)?/;
}
@gatlin
gatlin / orc-sample.lsp
Created Aug 11, 2012
Sample Orc DSL for Common Lisp
View orc-sample.lsp
; examples from http://orc.csres.utexas.edu/tryorc.shtml#tryorc/tutorial/
; site definition, similar to a function but handles network transparency and will publish multiple values if you call them
; multiple times
; they will necessarily hide much magic
(defsite name (arg)
(body ...))
; I may consider using plain-old functions for this but at the moment I might need to hide some magic
@gatlin
gatlin / main.go
Created Aug 13, 2012
Concepts from Orc applied in Go
View main.go
package main
import (
"fmt"
"github.com/gatlin/go-orc"
"net/http"
"time"
)
/*
@gatlin
gatlin / uninstall-haskell-osx.sh
Last active May 29, 2021
Uninstall Haskell from Mac OS X
View uninstall-haskell-osx.sh
#!/bin/bash
# source: http://www.haskell.org/pipermail/haskell-cafe/2011-March/090170.html
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf ~/.cabal
rm -rf ~/.ghc
rm -rf ~/Library/Haskell