Skip to content

Instantly share code, notes, and snippets.

@lispm
Created June 16, 2016 22:59
Show Gist options
  • Save lispm/702cd27264adf6a693bb6181acda3b69 to your computer and use it in GitHub Desktop.
Save lispm/702cd27264adf6a693bb6181acda3b69 to your computer and use it in GitHub Desktop.
(defun locate (x xs)
(let* ((r0 nil)
(r1 nil)
(r2 (substitute-if x
(lambda (a)
(when (< x a)
(setf r0 a r1 t)
t))
xs
:count 1)))
(values r0 r1 r2)))
; CL-USER 32 > (locate 3 '(0 1 2 4 5))
; 4
; T
; (0 1 2 3 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment