Permalink
Browse files

add del-first, del-last funcs

  • Loading branch information...
1 parent b5750f4 commit 4896d16a577878b45bbc2daab07b6c8d6c7bb1d1 Artem Yankov committed Sep 24, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/memobot/sets.clj
View
@@ -2,13 +2,18 @@
(:use [memobot types]
[clojure.set]))
+(defn sadd!
+ "Add member to a set"
+ [s v]
+ (swap! s #(conj % v)))
+
(defn sadd-cmd
"Add one or more members to a set"
[k v]
(let [s (eval k)]
(if (not (contains? @s v))
(do
- (swap! s #(conj % v))
+ (sadd! s v)
1)
0)))
@@ -41,13 +46,18 @@
[k]
k)
+(defn srem!
+ "Remove member from a set"
+ [s m]
+ (swap! s #(disj % m)))
+
(defn srem-cmd
"Remove one or more members from a set"
[k v]
(let [s (eval k)]
(if (contains? @s v)
(do
- (swap! s #(disj % v))
+ (srem! s v)
1)
0)))

0 comments on commit 4896d16

Please sign in to comment.