Skip to content

Instantly share code, notes, and snippets.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MOVE_NONE 0
#define MOVE_LEFT 1
#define MOVE_RIGHT 2
typedef struct Rule {
@igorw
igorw / turel.clj
Last active August 29, 2015 13:57
(ns turel.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn not-membero
[x l]
(conde [(emptyo l)]
[(fresh [head tail]
(conso head tail l)
(!= head x)
(ns turel.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn not-membero
[x l]
(conde [(emptyo l)]
[(fresh [head tail]
(conso head tail l)
(!= head x)
(ns coins.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic)
(:require [clojure.core.logic.fd :as fd]))
; find possible coin configurations
;
; $coins = [2, 3, 5, 7, 9];
; $a + ($b * pow($c, 2)) + pow($d, 3) - $e
git init a && cd a && touch hi && git add . && git commit -am 'hi a' && cd ..
git clone --bare a b
git clone b c && cd c && touch hi-from-c && git add . && git commit -am 'hi from c' && git push && cd ..
cd a && git remote add origin ../b && git pull origin master && ls && git log && cd ..
@igorw
igorw / mu.clj
Created April 17, 2014 21:04
MU puzzle from Douglas Hofstadter's Gödel, Escher, Bach. Implemented in core.logic.
(ns mu.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn i
[in out]
(conde [(== in [:I])
(== out [:I :U])]
[(fresh [in-head out-head]
(== in-head out-head)
@igorw
igorw / pq.clj
Created April 22, 2014 08:29
pq system from Douglas Hofstadter's Gödel, Escher, Bach. Implemented in core.logic.
(ns pq.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
; pq system
; formal string rewriting system representing addition
; from chapter II of Gödel, Escher, Bach by Douglas Hofstadter
(defn axiomo
[a b c]
<?php
require 'vendor/autoload.php';
use MicroKanren\Core as µ;
$goal = µ\callFresh(function ($q) {
return µ\disj(
µ\eq($q, 'foo'),
µ\eq($q, 'lulz')
@igorw
igorw / moar-ukanren.php
Created April 29, 2014 08:49
More fun with PHPµKanren!
<?php
require 'vendor/autoload.php';
use MicroKanren\Core as µ;
function membero($x, $l) {
return µ\disjPlus(
µ\fresh(function ($tail) use ($x, $l) {
return µ\eq($l, µ\cons($x, $tail));
@igorw
igorw / mutation.php
Created May 5, 2014 18:28
Self-modifying quasi-quine. Try running it, then piping the output into PHP. Then piping that output into PHP again. Then piping that output into PHP again. Then piping that output into PHP again. Then piping that output into PHP again. Then piping that output into PHP again.
<?php
$data = <<<'DATA'
$program = <<<PROGRAM
<?php
\$data = <<<'DATA'\n$data\nDATA;
$data
PROGRAM;
$n = 0;
if ($n >= 5) {