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 remove-duplicates | |
"Returns a lazy sequence of the elements of coll with duplicates removed using a predicate" | |
[coll pred] | |
(let [step (fn step [xs seen] | |
(lazy-seq | |
((fn [[f :as xs] seen] | |
(when-let [s (seq xs)] | |
(if (some #(pred f %) seen) | |
(recur (rest s) seen) | |
(cons f (step (rest s) (conj seen f)))))) |
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 ident.viterbi | |
(:use [clojure.pprint])) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Example | |
;; (def initpr (to-array [0.6 0.4])) | |
;; (def transpr (to-array-2d [[0.7 0.3][0.4 0.6]])) | |
;; (def emisspr (to-array-2d [[0.1 0.4 0.5][0.6 0.3 0.1]])) | |
;; (def hmm (make-hmm {:states ["rainy" "sunny"] :obs ["walk" "shop" "clean"] :init-probs initpr :emission-probs emisspr :state-transitions transpr})) | |
;; optimal state sequence and probability of sequence |
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
(declare ^:dynamic myvar) | |
(def myvar nil) | |
(defn mycounter [x] | |
(inc x)) | |
(defn testdynvar [x] | |
(myvar x)) |
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 [java.util HashMap]) | |
(def mymap (new HashMap)) | |
(. mymap put (hash "http://www.google.com/") "serp") | |
(def myhash (hash "http://www.google.com/")) | |
myhash | |
;;-87748806 | |
(. mymap get myhash) | |
;;"serp" | |
(spit "mytest.fb" (into {} mymap)) | |
(def mymap2 (java.util.HashMap. (read-string (slurp "mytest.fb")))) |
OlderNewer