This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?hh | |
// examples: | |
// | |
// ~$ echo '1 jnz(:start) :foo call(:bar) ret :bar 42 print ret :start call(:foo)' | hhvm vm.php | |
// float(42) | |
// | |
// ~$ echo '3 :loop 1 - print jnz(:loop)' | hhvm vm.php | |
// float(2) | |
// float(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?hh | |
// concatenative programming | |
// based on this paper: | |
// http://mitarbeiter.hs-heilbronn.de/~herzberg/Publications/ICSOFT.2009.pdf | |
namespace igorw\concat; | |
class OpenQuotation { | |
var $words; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = <<<'DATA' | |
$program = <<<PROGRAM | |
<?php | |
\$data = <<<'DATA'\n$data\nDATA; | |
$data | |
PROGRAM; | |
$n = 0; | |
if ($n >= 5) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use MicroKanren\Core as µ; | |
$goal = µ\callFresh(function ($q) { | |
return µ\disj( | |
µ\eq($q, 'foo'), | |
µ\eq($q, 'lulz') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 .. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |