mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 01:07:34 +02:00
Faster version of _list-index
This commit is contained in:
parent
a72e91b85c
commit
1f7212a964
1 changed files with 5 additions and 9 deletions
|
@ -1864,16 +1864,12 @@
|
|||
(lambda (obj val)
|
||||
(vector-set! (vector-ref obj 2) idx val)))
|
||||
|
||||
;; Find index of element in list, or -1 if not found
|
||||
;; Find index of element in list, or #f if not found
|
||||
(define _list-index
|
||||
(lambda (e lst)
|
||||
(if (null? lst)
|
||||
-1
|
||||
(if (eq? (car lst) e)
|
||||
0
|
||||
(if (= (_list-index e (cdr lst)) -1)
|
||||
-1
|
||||
(+ 1 (_list-index e (cdr lst))))))))
|
||||
(lambda (e lst1)
|
||||
(let lp ((lis lst1) (n 0))
|
||||
(and (not (null? lis))
|
||||
(if (eq? e (car lis)) n (lp (cdr lis) (+ n 1)))))))
|
||||
|
||||
(define (record? obj)
|
||||
(and (vector? obj)
|
||||
|
|
Loading…
Add table
Reference in a new issue