Skip to content

Commit

Permalink
Add (rnrs lists)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpk committed Oct 18, 2024
1 parent 472c728 commit d61e916
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/rnrs/lists.sld
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(library (rnrs lists)
(export find
(rename every for-all)
(rename any exists)
filter partition
fold-left
fold-right
(rename remove remp)
(rename rnrs:remove remove)
remv
remq
(rename find-tail memp)
member
memv
memq
assp
assoc
assv
assq
cons*)
(import (scheme base)
(srfi 1))

(define (fold-left kons knil . lss)
(apply fold
(lambda args
(apply kons (last args) (drop-right args 1)))
knil lss))

(define (rnrs:remove obj ls) (remove (lambda (x) (equal? x obj)) ls))
(define (remv obj ls) (remove (lambda (x) (eqv? x obj)) ls))
(define (remq obj ls) (remove (lambda (x) (eq? x obj)) ls))

(define (assp proc alist)
(find (lambda (x) (proc (car x))) alist)))

0 comments on commit d61e916

Please sign in to comment.