Skip to content

Instantly share code, notes, and snippets.

@guipdutra
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guipdutra/875481ed07370ce05517 to your computer and use it in GitHub Desktop.
Save guipdutra/875481ed07370ce05517 to your computer and use it in GitHub Desktop.
(defn next-item [array elem]
(get (into-array array) (inc (.indexOf array elem))))
(fact "next-item"
(next-item (range 1 25) 12) => 13
(next-item [:a :b :c] :b) => :c)
@erickpintor
Copy link

(defn next-item 
  [arr elem]
  (let [[_ split] (split-with 
                    (partial not= elem) arr)]
    (second split)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment