Skip to content

Instantly share code, notes, and snippets.

View forestbelton's full-sized avatar

Forest Belton forestbelton

View GitHub Profile
@forestbelton
forestbelton / Env.pm
Last active June 26, 2021 10:49
A basic LISP interpreter in Perl
#!/usr/bin/env perl
use strict;
use warnings;
package Env;
sub new {
my $class = shift;
my $names = shift;
@forestbelton
forestbelton / CNF.hs
Created February 24, 2013 04:18
A naive SAT solver in Haskell
import qualified Data.Set as Set
data Clause = Value Bool | Not Int | Literal Int | Or Clause Clause deriving (Eq,Ord)
type CNF = Set.Set Clause
instance Show Clause where
show (Value True) = "T"
show (Value False) = "F"
show (Not x) = "~" ++ show x
show (Literal x) = show x
@forestbelton
forestbelton / nsify.js
Created February 24, 2013 04:11
Prepends class / id selectors with "ns_" if data-namespace="ns" is given on the <link> tag.
(function() {
var nsify = function(ns, selChunk) {
sels = selChunk.replace(/ /g, '').split(',');
for(var i = 0; i < sels.length; ++i)
if(sels[i][0].match(/[.#]/))
sels[i] = sels[i][0] + ns + '-' + sels[i].substring(1);
return sels.join(',');