Skip to content

Instantly share code, notes, and snippets.

View README.md

bf

A Clojure library designed to ... well, that part is up to you.

Usage

$ lein run ">++++++++[<+++++++++>-]<.>>+>+>++>[-]+<[>[->+<<++++>]<<]>.+++++++..+++.>>+++++++.<<<[[-]<[-]>]<+++++++++++++++.>>.+++.------.--------.>>+.>++++."
Hello World!

License

View fannkuch.clj
(ns fannkuch.core
(:require [clojure.math.combinatorics :as combo]))
; Fannkuchen
;
; it's super slow though
; also I was too stupid to implement permutations, so I used Mark Engelberg's library
;
; https://www.haskell.org/haskellwiki/Shootout/Fannkuch
View divmod.s.diff
--- divmod2.s 2015-01-09 21:58:10.000000000 +0100
+++ divmod.s 2015-01-09 21:56:08.000000000 +0100
@@ -12,20 +12,27 @@
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
- leaq _divmod.n(%rip), %rax
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
- movl -4(%rbp), %esi
View divmod.clj
(ns divmod.core)
; division by repeated subtraction
; http://en.wikipedia.org/wiki/Division_algorithm#Division_by_repeated_subtraction
(defn divmod
[n d]
(cond
(= d 0) (throw (Throwable. "Division By Zero"))
(< d 0)
@igorw
igorw / mu.scm
Created Jan 7, 2015
GEB MU puzzle in miniKanren
View mu.scm
; Douglas Hofstadter's MU puzzle from Gödel, Escher, Bach
; written in miniKanren
;
; https://github.com/miniKanren/miniKanren/blob/master/mk.scm
(load "mk.scm")
(define print
(lambda (exp)
(display exp)
View imitating-kayla.php
<?php
$permutations = [
['a', 'c', 'f'],
['b', 'd'],
['a', 'b', 'd'],
['e', 'f'],
];
/*
View interp.clj
(ns interp.core)
(def empty-state {:ip 0, :code [], :stack '(), :labels {}})
(defn step
[state]
(let [instr (get (:code state) (:ip state))
state (update-in state [:ip] inc)]
(cond
(nil? instr)
View avl-tree.php
<?php
// AVL tree
class Node {
public $value;
public $left;
public $right;
public $height;
@igorw
igorw / fox-goose-bag-of-corn.scm
Created Dec 28, 2014
miniKanren implementation of Lewis Carroll's "Fox, Goose, and Bag of Corn" puzzle, described by Carin Meier (@gigasquid)
View fox-goose-bag-of-corn.scm
; miniKanren solution to fox-goose-bag-of-corn
; https://github.com/gigasquid/wonderland-clojure-katas/blob/master/fox-goose-bag-of-corn/README.md
(load "mk.scm")
(define print
(lambda (exp)
(display exp)
(newline)))
@igorw
igorw / fizz-buzzo.scm
Last active Aug 29, 2015
fizzbuzz in miniKanren. See also minikanren.org and github.com/webyrd/miniKanren-uncourse
View fizz-buzzo.scm
(load "mk.scm")
(define print
(lambda (exp)
(display exp)
(newline)))
(define peanoo
(lambda (n)
(conde
You can’t perform that action at this time.