Skip to content

Commit

Permalink
test list-remove
Browse files Browse the repository at this point in the history
  • Loading branch information
benknoble committed Nov 13, 2023
1 parent 8373df6 commit c33ab1b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions qi/utils.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,22 @@

(require qi)

(module+ test (require rackunit))

(define-flow (list-remove _xs _i)
(~> split-at
(-< (~> (== _ cdr) append)
(~> 2> car))))

(module+ test
(test-case "list-remove"
(define-flow list-remove1 (~> list-remove 1>))
(define-flow list-remove2 (~> list-remove 2>))
(check-equal? (list-remove1 '(a b c) 0) '(b c))
(check-equal? (list-remove1 '(a b c) 1) '(a c))
(check-equal? (list-remove1 '(a b c) 2) '(a b))
(check-equal? (list-remove2 '(a b c) 0) 'a)
(check-equal? (list-remove2 '(a b c) 1) 'b)
(check-equal? (list-remove2 '(a b c) 2) 'c)
(for ([i '(-1 3 4 5 10)])
(check-exn exn:fail? (thunk (list-remove '(a b c) i))))))

0 comments on commit c33ab1b

Please sign in to comment.