Skip to content

Commit

Permalink
add sublist-lens
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKnauth committed Jul 11, 2015
1 parent 91de3c7 commit 4fce8ff
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions unstable/lens/sublist.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#lang racket/base

(provide sublist-lens)

(require lens/base/main
lens/list/main
)
(module+ test
(require rackunit))

(define (sublist-lens i j)
(lens-thrush (take-lens j) (drop-lens i)))

(module+ test
(check-equal? (lens-view (sublist-lens 1 3) '(0 1 2 3 4 5))
'(1 2 3))
(check-equal? (lens-set (sublist-lens 1 3) '(0 1 2 3 4 5) '(a b c))
'(0 a b c 4 5))
)

0 comments on commit 4fce8ff

Please sign in to comment.