 ;; <=
 
 ;; @@
-
-;; @@
+(with-primitive-procedures [normalize]
+  (defquery even [observedsequence alphabet]
+    (let [num-states 2
+
+          emissiondist (fn [state] 
+                         (if (= state 0)
+                           (categorical [["a" 0.5] ["b" 0.5]])
+                           (categorical [["a" 0.0] ["b" 1.0]]))) ; \pi
+
+          transition (fn [state symbol]
+                       (case [state symbol]
+                         [0 "a"] 0
+                         [0 "b"] 1
+                         [1 "a"] 0
+                         [1 "b"] 0)) ; \delta
+          ]
+
+      (loop [obs observedsequence
+             state [0]]
+        (if (not (empty? obs))
+          (let [currentstate (peek state)
+                _ (observe (emissiondist currentstate) (first obs))
+                nextstate (transition currentstate (first obs))]
+            (recur (rest obs)
+                   (conj state nextstate)))
+          (new-pdfa alphabet num-states transition emissiondist))))))
+
+(def num-particles 1)
+(def is-states (take num-particles (infer :importance even [test-observations-str alphabet])))
+;; @@
+;; =>
+;;; {"type":"html","content":"<span class='clj-var'>#&#x27;pdfa/is-states</span>","value":"#'pdfa/is-states"}
+;; <=
+
+;; @@
+(view-top-n-pdfas is-states 1)
+;; @@
+;; =>
+;;; {"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMUAAAC1CAYAAADvGjsxAAActElEQVR42u2dCdgN5fvH21eVdqVVURElRNpLtpIWIS3SIsqWLMlSos1WtihLRISIQlJkr6iQtFEpUrJEpVU9v+tz///P23HMOWfmvHPeM2fm/l7XXC7nnbPMM893nvu5l++9mzGmjx566PHfsZtRKBQ7QUmhUCgpFAolhUIRXlL8888/ZtWqVWbWrFlm1KhR5sknnzT33Xefufvuu82tt95qbrjhBnPNNdeY+vXrm9tuu800bdrUtG/f3jz99NNm/PjxZsGCBeb777/Xu67ITVL8+++/ZsWKFWbAgAGmYcOG5pxzzjH777+/2W233fKOQw891JQsWdJUqFDBXHTRRaZq1armyiuvNFWqVDHnn3++KVeunDn11FPNAQccsNP7Dj/8cHPxxRebZs2amTFjxpjvvvtOZ4IimKTYunWrrADXX3+9TFwm8D777GMqVqxo7rzzTnniv/XWW+bLL780v//+u+fP/uSTT8wrr7xiunfvLqvJ6aefnkcUyMPK8uabb5q///5bZ4aSInv466+/xLSpUaOGEGD33Xc3lSpVMg8//LCZPXu2+e233zL6/T/++KOZOHGiadGihTn55JOFIIcddpi54447zLvvvqszRElRcFi/fr158MEHTZEiRWQiXnDBBWbgwIFZN2WWLl1qOnfunEeQs88+2zz77LPmjz/+0NmipMgM2Oi2atXK7LfffqZw4cLyhF65cmUg9zQzZsww1157rdlzzz1N0aJFZX+j5FBS+AYmU9euXWWzzAb5kUceETs/F/DFF1+IdwtynHDCCWJuKZQU+cLMmTNlI8ueoUOHDubnn3/OycHCHVyrVi0xq9gDffXVVzqDlBTe8Oeff0ocgUmEm/Szzz4LxaC99tprsuc4+OCDzdixY3UWKSnc4ZtvvjHly5c3++67r7hSwwZWu5tuukkIf9ddd8kDQKGkSIiPPvrIHHvssfI0xZsTZowYMUKIf/nll+esWajIMClIpTjkkEMkmvzDDz9EYhDnzp0rzoOyZcuajRs36qxSUuy8QuBmveSSS8wvv/wSqYHErXzUUUeZc8891/z66686s5QUxnz77bdiMpGjFFUz4sMPP5TNN56pHTt26OyKMimYAESk8eGTNhFlkJtFPOPmm282nTp1kkAlG/Hbb79dMndJbiSrl9f5O06IF1980cyZM0ecE2QCK0JACoJyTAT2EwpjHnroIcnhIoWlVKlSYlKdd9558uAgexevHK8ff/zxu2TwsmlntSX3aujQoZL8qMgxUqxevdrsvffepkuXLjqaMSsnJChdurSrJ//27dvNp59+al5//XVZOVhVyLnaY489hCjFixeXPLEgpsMoKRxQt25dc9xxx2U8mzXX8N5778lq8fzzz6f9GaTBTJkyxTRq1CgvlR7XL0VWioCSgiIgbhS++mzj/fffl3RzkvaWL18uCX3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nL8pL4olBQJ0aNHDzGlsLFJCQkj3n33XXPyySeLYAJlsQolRUrQF44AFg3cp02bFqoNNc3tKTOtXLlyYHSvFDlACvDDDz/IaoE5de2115o1a9bk9IDNnj3blCxZUgjx4IMPSmtkhZIiLUyYMMEULVrUHHDAAVKamWsm1dKlS4XUkPuCCy4wK1as0NmjpMg/CGx16dLFHHLIIUKO1q1bm6+++irQA8ReoXbt2kIGovb03wi780BJkQUgDEYKxKGHHipuzGrVqonnJihN2zdu3CiSNJhJkIFWA4ia0b5MoaTIKBBEJhJeqVIlmXxEguvXry++flydBQn2Ov379xf3KnEWUr4pEGIPoVBSZAXUZHTv3l30pCAIKwhN6VEiRK+WWme/NrUkLi5evNg899xzokhC+jvfSTQap8DQoUNltVAoKQIDXJysINQiFCtWLE8jlklbpkwZsfGbNm1qunXrJjXQY8eONZMnTzYzZsyQFIvp06ebiRMniv0/cOBA06lTJ+mhgZlGXIH4CZ/HioBUDw0c6ea6bds2nRGKYJIiHpR1zp07V2RiIAPyOmXLlpUYiJ3giQ7MoBNOOEFMNIqh8HyRm0Wfvt9++01ngCI3SZEM//zzj9m+fbvZtGmTFPTgzVq/fr3ZsmWL7FkUisiRQqFQUigUSgqFQkmhUGQV/wNavU1kp6UMSAAAAABJRU5ErkJggg==\" width=\"197\" height=\"181\" alt=\"\" />","value":"#object[java.awt.image.BufferedImage 0x7a3b46f8 \"BufferedImage@7a3b46f8: type = 6 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@5c5bc4fa transparency = 3 has alpha = true isAlphaPre = false ByteInterleavedRaster: width = 197 height = 181 #numDataElements 4 dataOff[0] = 3\"]"},{"type":"html","content":"<span class='clj-double'>-47.13400827807628</span>","value":"-47.13400827807628"}],"value":"[#gorilla_repl.image.ImageView{:image #object[java.awt.image.BufferedImage 0x7a3b46f8 \"BufferedImage@7a3b46f8: type = 6 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@5c5bc4fa transparency = 3 has alpha = true isAlphaPre = false ByteInterleavedRaster: width = 197 height = 181 #numDataElements 4 dataOff[0] = 3\"], :alt \"\", :type \"png\", :width 197, :height 181} -47.13400827807628]"}],"value":"[[#gorilla_repl.image.ImageView{:image #object[java.awt.image.BufferedImage 0x7a3b46f8 \"BufferedImage@7a3b46f8: type = 6 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@5c5bc4fa transparency = 3 has alpha = true isAlphaPre = false ByteInterleavedRaster: width = 197 height = 181 #numDataElements 4 dataOff[0] = 3\"], :alt \"\", :type \"png\", :width 197, :height 181} -47.13400827807628]]"}
+;; <=
+
+;; @@
+
+;; @@

(sample-observes-from-prior pdfa [(repeat 10 nil) alphabet])
;; @@
;; =>
;;; {"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>0</span>","value":"0"}],"value":"[:time-index 0]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>0</span>","value":"0"}],"value":"[:observe-instance 0]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 0, :observe-address O44, :observe-instance 0, :value 1}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>1</span>","value":"1"}],"value":"[:time-index 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>1</span>","value":"1"}],"value":"[:observe-instance 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 1, :observe-address O44, :observe-instance 1, :value 0}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>2</span>","value":"2"}],"value":"[:time-index 2]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>2</span>","value":"2"}],"value":"[:observe-instance 2]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 2, :observe-address O44, :observe-instance 2, :value 1}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>3</span>","value":"3"}],"value":"[:time-index 3]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>3</span>","value":"3"}],"value":"[:observe-instance 3]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 3, :observe-address O44, :observe-instance 3, :value 1}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>4</span>","value":"4"}],"value":"[:time-index 4]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>4</span>","value":"4"}],"value":"[:observe-instance 4]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 4, :observe-address O44, :observe-instance 4, :value 0}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>5</span>","value":"5"}],"value":"[:time-index 5]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>5</span>","value":"5"}],"value":"[:observe-instance 5]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 5, :observe-address O44, :observe-instance 5, :value 1}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>6</span>","value":"6"}],"value":"[:time-index 6]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>6</span>","value":"6"}],"value":"[:observe-instance 6]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 6, :observe-address O44, :observe-instance 6, :value 1}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>7</span>","value":"7"}],"value":"[:time-index 7]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>7</span>","value":"7"}],"value":"[:observe-instance 7]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 7, :observe-address O44, :observe-instance 7, :value 1}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>8</span>","value":"8"}],"value":"[:time-index 8]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>8</span>","value":"8"}],"value":"[:observe-instance 8]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 8, :observe-address O44, :observe-instance 8, :value 1}"},{"type":"list-like","open":"<span class='clj-map'>{</span>","close":"<span class='clj-map'>}</span>","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:time-index</span>","value":":time-index"},{"type":"html","content":"<span class='clj-unkown'>9</span>","value":"9"}],"value":"[:time-index 9]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-address</span>","value":":observe-address"},{"type":"html","content":"<span class='clj-symbol'>O44</span>","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:observe-instance</span>","value":":observe-instance"},{"type":"html","content":"<span class='clj-unkown'>9</span>","value":"9"}],"value":"[:observe-instance 9]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":"<span class='clj-keyword'>:value</span>","value":":value"},{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 9, :observe-address O44, :observe-instance 9, :value 0}"}],"value":"[{:time-index 0, :observe-address O44, :observe-instance 0, :value 1} {:time-index 1, :observe-address O44, :observe-instance 1, :value 0} {:time-index 2, :observe-address O44, :observe-instance 2, :value 1} {:time-index 3, :observe-address O44, :observe-instance 3, :value 1} {:time-index 4, :observe-address O44, :observe-instance 4, :value 0} {:time-index 5, :observe-address O44, :observe-instance 5, :value 1} {:time-index 6, :observe-address O44, :observe-instance 6, :value 1} {:time-index 7, :observe-address O44, :observe-instance 7, :value 1} {:time-index 8, :observe-address O44, :observe-instance 8, :value 1} {:time-index 9, :observe-address O44, :observe-instance 9, :value 0}]"}
;; <=

;; @@
(combine-observes-fn (sample-observes-from-prior pdfa [(repeat 10 nil) alphabet]))
;; @@
;; =>
;;; {"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"},{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"},{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"},{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"},{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"<span class='clj-vector'>[</span>","close":"<span class='clj-vector'>]</span>","separator":" ","items":[{"type":"html","content":"<span class='clj-long'>1</span>","value":"1"},{"type":"html","content":"<span class='clj-long'>0</span>","value":"0"}],"value":"[1 0]"}],"value":"[[0 1] [1 0] [0 1] [0 1] [1 0] [0 1] [0 1] [1 0] [0 1] [1 0]]"}
;; <=

;; **

;; **

;; @@
(def alphabet (map str "ab"))
(def alphabet-len (count alphabet))
(defn one-hot [len hot]
  (assoc (vec (replicate len 0)) hot 1))
