Created
June 16, 2016 22:59
-
-
Save lispm/702cd27264adf6a693bb6181acda3b69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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