mes: Add list-index.

* module/srfi/srfi-1.scm (list-index): New function.
This commit is contained in:
Jan Nieuwenhuizen 2017-06-11 14:45:01 +02:00
parent 2c0f5c346c
commit 01b4c0846b

View file

@ -65,6 +65,21 @@
(else
(and (pred (car ls)) (lp (cdr ls)))))))
(define (list-index pred clist1 . rest)
(if (null? rest)
(let lp ((l clist1) (i 0))
(if (null? l)
#f
(if (pred (car l))
i
(lp (cdr l) (+ i 1)))))
(let lp ((lists (cons clist1 rest)) (i 0))
(cond ((any1 null? lists)
#f)
((apply pred (map car lists)) i)
(else
(lp (map cdr lists) (+ i 1)))))))
;;; Set operations on lists
(define (lset-union = . rest)