Is there a standard function testing if a sequence starts with a sequence

1 view
Skip to first unread message

samppi

unread,
Jul 17, 2009, 4:32:01 PM7/17/09
to Clojure
Is there a function in clojure.core or clojure.contrib so that:
(and (mystery-fn '(a b c d) '(a b))
(not (mystery-fn '(a b c d) '(a b d))))

Mark Engelberg

unread,
Jul 17, 2009, 4:41:34 PM7/17/09
to clo...@googlegroups.com


how about something like:
(defn mystery-fn [l1 l2] (every? identity (map = l1 l2)))

samppi

unread,
Jul 17, 2009, 4:51:23 PM7/17/09
to Clojure
Awesome, thanks for the quick answer. I think that it'd be a useful
thing to add to seq-utils or something. :)

On Jul 17, 1:41 pm, Mark Engelberg <mark.engelb...@gmail.com> wrote:

John Harrop

unread,
Jul 17, 2009, 6:02:29 PM7/17/09
to clo...@googlegroups.com
user=> (mystery-fn '(a b) '(a b c d))
true

How about something like:
(defn mystery-fn [l1 l2] (and (<= (count l2) (count l1)) (every? identity (map = l1 l2))))
Reply all
Reply to author
Forward
0 new messages