This file contains 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 mnemonics.core | |
(:require [clojure.string :as str :only (lower-case)]) | |
(:use [clojure.contrib.duck-streams :only (read-lines)])) | |
(def *number-pairs* | |
{ 0 "e" 1 "jnq" 2 "rwx" 3 "dsy" 4 "ft" 5 "am" 6 "civ" 7 "bku" 8 "lop" 9 "ghz"}) | |
(defn pair-list | |
[n cs] | |
(map #(hash-map % n) cs)) |
This file contains 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
; (to-html (number-a-sequence (map track-to-str (top-tracks lastfm-user-name (lastfm-api-key)))))) | |
(defmacro with-error-handling | |
[func return_on_ok return_on_fail & args] | |
`(let [result# (apply func ~args)] | |
(if (.isSuccessful result#) | |
~return_on_ok | |
~return_on_fail))) | |
;(with-error-handling (fn [a b] (Library/addArtist a b)) "OK" "FAIL" "Murk" (get-session)) |
This file contains 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
(defn path | |
[[x & more :as full-list] orgmat p] | |
(let [maxsize (count orgmat) | |
new-row (- (count more)) | |
this-row (count more)] | |
(cond | |
(empty? full-list) p | |
(= this-row 0) p | |
(= x 0) (recur more orgmat p) | |
(= x 1) (if (< new-row (last p)) |
This file contains 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
(defn test-test | |
[[x & more :as list] orgmat p] | |
(cond | |
(empty? list) p | |
(= x 1) (test-test (nth orgmat (count more)) orgmat (conj p (count more))) | |
(= x 0) (recur more orgmat p) | |
true (recur more orgmat p))) | |
orgmat is in form: | |
((0 0 0 0 0 0 0 0) (1 0 1 0 0 1 0 0) (1 0 0 0 0 1 0 0) (1 1 1 0 0 1 0 0) (1 1 1 1 0 1 0 1) (1 0 0 0 0 0 0 0) (1 1 1 1 1 1 0 1) (1 1 1 1 0 1 0 0)) |
This file contains 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
(defn path | |
[[x & more :as full-list] orgmat p] | |
(let [maxsize (count orgmat) | |
new-row (- (count more) 1) | |
this-row (+ new-row 1)] | |
(cond | |
(empty? full-list) (conj p this-row) | |
(= x 0) (path more orgmat p) | |
(= x 1) (if (>= new-row (last p)) | |
(path more orgmat p) |
This file contains 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 user.core | |
(:use [clojure.contrib.duck-streams :only (read-lines)])) | |
(declare lcs) ; Declare the memoized lcs | |
(def *file-name* "/Users/svdberg/boxes.txt") | |
(defn longest [xs ys] (if (> (count xs) (count ys)) xs ys)) | |
(defn undecorated-lcs [seqx seqy] |
This file contains 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
import Text.CSV | |
type FirstName = String | |
type LastName = String | |
type MiddleName = String | |
type FullName = String | |
type PhoneNumber = String | |
data Contact = Contact | |
{ firstname :: FirstName |
NewerOlder