Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (22 sloc) 0.535 kB
(ns hash-table)
(def m 256)
(defn make-table []
(vec (repeat m '())))
(defn hash-key [x]
(rem (hash x) m))
(defn search [table x]
(let [k (hash-key x)
bucket (nth table k)]
(some #{x} bucket)))
(defn insert [table x]
(let [k (hash-key x)
bucket (nth table k)]
(if (some #{x} bucket)
table
(assoc table k (conj bucket x)))))
(defn delete [table x]
(let [k (hash-key x)
bucket (nth table k)]
(if (some #{x} bucket)
(assoc table k (remove #{x} bucket))
table)))
Jump to Line
Something went wrong with that request. Please try again.