mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-17 01:37: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)
|
(lambda (obj val)
|
||||||
(vector-set! (vector-ref obj 2) idx 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
|
(define _list-index
|
||||||
(lambda (e lst)
|
(lambda (e lst1)
|
||||||
(if (null? lst)
|
(let lp ((lis lst1) (n 0))
|
||||||
-1
|
(and (not (null? lis))
|
||||||
(if (eq? (car lst) e)
|
(if (eq? e (car lis)) n (lp (cdr lis) (+ n 1)))))))
|
||||||
0
|
|
||||||
(if (= (_list-index e (cdr lst)) -1)
|
|
||||||
-1
|
|
||||||
(+ 1 (_list-index e (cdr lst))))))))
|
|
||||||
|
|
||||||
(define (record? obj)
|
(define (record? obj)
|
||||||
(and (vector? obj)
|
(and (vector? obj)
|
||||||
|
|
Loading…
Add table
Reference in a new issue