Skip to content

Instantly share code, notes, and snippets.

@ibdknox
Created August 1, 2011 01:34
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 ibdknox/1117436 to your computer and use it in GitHub Desktop.
Save ibdknox/1117436 to your computer and use it in GitHub Desktop.
#(:longest
(reduce
(fn [{:keys [longest cur] :as res} n]
(let [{:keys [cur] :as updated} (if (or (not (seq cur))
(> n (last cur)))
(update-in res [:cur] conj n)
(assoc res :cur [n]))
longest-cnt (count longest)
cur-cnt (count cur)]
(if (and (> cur-cnt 1)
(> cur-cnt longest-cnt))
(assoc updated :longest cur)
updated)))
{:longest [] :cur []} %))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment