Skip to content

Instantly share code, notes, and snippets.

View swannodette's full-sized avatar

David Nolen swannodette

View GitHub Profile
  • remove -snapshot from version number in both package.json and project.clj
  • probably run the tests one more time to make sure all is well
  • add and commit changes with git
  • create a git tag for to-be-released version
  • push the commits and tag out to github
  • run npm publish . (may need to re/register with npmjs.org)
  • deploy to clojars (maybe?)
  • assuming all goes well, bump the version number and append -snapshot in both package.json and project.clj
(ns pettomato.findall
(:refer-clojure :exclude [==])
(:use
[clojure.core.logic.protocols])
(:require
[clojure.core.logic :refer :all]))
(defn findall
"A goal that unifies l with a lazy sequence containing all possible
instantiations of v that could be generated by applying the goal g
(ns hacklheber.core)
(defn flip
"A function which returns true or false randomly. Can optionally be
supplied a number for a bias."
([] (> 0.5 (rand)))
([p] (> p (rand))))
(defn- memo-bangs
"If a variable is bound with a bang, then it will be memoized."
/*
* Nonogram/paint-by-numbers solver in SWI-Prolog. Uses CLP(FD),
* in particular the automaton/3 (finite-state/RE) constraint.
* Copyright (c) 2011 Lars Buitinck.
* Do with this code as you like, but don't remove the copyright notice.
*/
:- use_module(library(clpfd)).
nono(RowSpec, ColSpec, Grid) :-
(ns lucenalog.core
"Lucenalog = Datalog interface to Lucene in 10 lines.
Simple but powerful.
Use
(db/add (index) {:a \"foo\" :b \"bar\"})
to index a map with Lucene. Then you can use the relation
(defmacro assumedTrue
"will throw if any of the passed expressions evaluate to false or nil"
[& _] ;allows 0 or more params, but 0 params will throw and allow you to see the original line number
;(pri "` lexical env: `" ~a)
`(do
(let [myname# '~(first &form) ;aka the name of this macro
allPassedForms# '~(rest &form) ;all parameters passed to this macro
]
(cond (<= (count allPassedForms#) 0)
(throw
;; Symbolic differentiation
;;
;; translated from aprolog/examples/diff.apl
;; http://homepages.inf.ed.ac.uk/jcheney/programs/aprolog/examples/diff.apl
;;
(ns nominal.diff
(:refer-clojure :exclude [==])
(:use [clojure.core.logic :exclude [is] :as l]
[clojure.core.logic.nominal :exclude [fresh hash] :as nom])
(define-syntax prefix-sum
(syntax-rules ()
((_ ((pvar ps) ...) body)
(prefix-sum* ((pvar ps) ...) 0 body))))
(define-syntax prefix-sum*
(syntax-rules ()
((_ () acc body) body)
((_ ((pvar ps) (pvar* ps*) ...) acc body)
(let ((pvar (+ ps acc)))
@swannodette
swannodette / gist:4156747
Created November 27, 2012 20:18 — forked from lynaghk/gist:4116442
Possible syntaxes for flexible unifier w/ multi-lvar constraints
;;Support for simple constraints on lvars during unification was added in 76fd4d7c:
;;
;; https://github.com/clojure/core.logic/commit/76fd4d7c155161d74ad5cd8d87955148eece1fe0
;;
;;but these constraints apply to a single lvar only.
;;The unifier could support more general constraints if it accepted an explicit predicate function.
;;For instance, given this `data-numeric?` predicate and `spec` data:
(defn data-numeric? [data dimension]