Skip to content

Instantly share code, notes, and snippets.

View frenchy64's full-sized avatar

Ambrose Bonnaire-Sergeant frenchy64

  • Madison, Wisconsin
View GitHub Profile
@frenchy64
frenchy64 / Clojure print jars classpath
Created January 24, 2011 06:03
Print the name of all jars in the classpath
(for [class
(sort (re-seq #"[-a-zA-Z0-9.]*\.jar" (System/getProperty "java.class.path" ".")))]
(println class))
@frenchy64
frenchy64 / Clojure CSV indexing
Created January 29, 2011 17:09
Clean way to grab a particular column of each row
;; http://stackoverflow.com/questions/4830900/how-do-i-find-the-index-of-an-item-in-a-vector/4831170#4831170
;; CSV File:
;; first-name, last-name, phone <- headers (column names)
;; Ambrose, BS, 234333
;; Chris, Squire, 4333
;; 1. Extract to vector
@frenchy64
frenchy64 / .zshrc
Created March 3, 2011 02:31
.zshenv
# Set up the prompt
autoload -Uz promptinit
promptinit
prompt walters
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
@frenchy64
frenchy64 / Dispatch.java
Created March 11, 2011 11:21
Discussion on dispatch method of Java
public class Dispatch {
public static void main(String[] args) {
// Start here
// Java uses single dispatch.
//
// Single dispatch is based on the runtime "type" of d, which is Dog.
Dog d = new Dog();
<collection xmlns:ands="http://www.ands.org.au/ontologies/ns/0.1/VITRO-ANDS.owl#"
xmlns:bibo="http://purl.org/ontology/bibo/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:vivo="http://vivoweb.org/ontology/core#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:event="http://purl.org/NET/c4dm/event.owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
(ns logic-test.core
(:refer-clojure :exclude [inc reify ==])
(:use clojure.core.logic.prelude)
(:use clojure.core.logic.minikanren))
(defn secondo [l x]
(exist [r]
(resto l r)
(firsto r x)))
(run out-str
(js-statement out-str "println(\"asdf\");"))
#<StackOverflowError java.lang.StackOverflowError>
(run 4 [q]
(exist [a t]
(typedo [[:f :- a]
[:g :- :int]]
q
:int)))
;=> (:f
; :g
; [:apply :f :g]
(ns logic-introduction.core
(:refer-clojure :exclude [inc reify ==])
(:use [clojure.core.logic minikanren prelude nonrel match disequality]))
(defn geto [key env value]
(matche [env]
([[[key :- value] . _]])
([[_ . ?rest]] (geto key ?rest value))))
(defn typedo [context exp resulttype]
(ns logic-introduction.core
(:refer-clojure :exclude [inc reify ==])
(:use [clojure.core.logic minikanren prelude nonrel match disequality]))
(defn geto [key env value]
"Succeed if type association [key :- value] is found in vector env."
(matche [env]
([[[key :- value] . _]])
([[_ . ?rest]] (geto key ?rest value))))