Advertisement
Guest User

Untitled

a guest
Oct 11th, 2010
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.33 KB | None | 0 0
  1. (defn zero-if-nil [m k]
  2.   (let [x (m k)]
  3.     (if (nil? x)
  4.       0
  5.       x)))
  6.  
  7. (defn train [model features]
  8.   (loop [my-model model
  9.          my-features features]
  10.     (if (seq my-features)
  11.       (recur (assoc my-model (first my-features) (+ 1 (zero-if-nil my-model (first my-features)))) (rest my-features))
  12.       my-model)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement