Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrections to ilist= ievery and export list #6

Merged
merged 4 commits into from May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions ilists/ilists-impl.scm
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@
(others (cdr others)))
(if (eq? ilist-a ilist-b) ; EQ? => LIST=
(lp1 ilist-b others)
(let lp2 ((ilist-a ilist-a) (ilist-b ilist-b))
(if (null-ilist? ilist-a)
(and (null-ilist? ilist-b)
(let lp2 ((pair-a ilist-a) (pair-b ilist-b))
(if (null-ilist? pair-a)
(and (null-ilist? pair-b)
(lp1 ilist-b others))
(and (not (null-ilist? ilist-b))
(= (icar ilist-a) (icar ilist-b))
(lp2 (icdr ilist-a) (icdr ilist-b)))))))))))
(and (not (null-ilist? pair-b))
(= (icar pair-a) (icar pair-b))
(lp2 (icdr pair-a) (icdr pair-b)))))))))))



Expand Down Expand Up @@ -948,7 +948,7 @@
(define (ibreak pred lis) (ispan (lambda (x) (not (pred x))) lis))
(define (ievery pred lis1 . lists)
(check-arg procedure? pred ievery)
(if (ipair? lists)
(if (pair? lists)

;; N-ary case
(receive (heads tails) (%cars+cdrs (ipair lis1 lists))
Expand Down
10 changes: 7 additions & 3 deletions ilists/ilists-test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
(test (iq c c c c) (make-ilist 4 'c))
(test (iq 0 1 2 3) (ilist-tabulate 4 values))
(test (iq 0 1 2 3 4) (iiota 5))
(define abc-copy (ilist-copy abc))
(test abc abc-copy)
(test-assert (not (eq? abc abc-copy)))
) ; end ilists/constructors

(test-group "ilists/predicates"
Expand All @@ -30,6 +33,7 @@
(test-assert (not-ipair? 'a))
(test-assert (not (not-ipair? (ipair 'a 'b))))
(test-assert (ilist= = (iq 1 2 3) (iq 1 2 3)))
(test-assert (ilist= = (iq 1 2 3) (iq 1 2 3) (iq 1 2 3)))
(test-assert (not (ilist= = (iq 1 2 3 4) (iq 1 2 3))))
(test-assert (not (ilist= = (iq 1 2 3) (iq 1 2 3 4))))
(test-assert (ilist= = (iq 1 2 3) (iq 1 2 3)))
Expand Down Expand Up @@ -268,8 +272,8 @@
(test #t (iany even? (iq 1 2 3)))
(test #f (ifind even? (iq 1 7 3)))
(test #f (iany even? (iq 1 7 3)))
(test-error (ifind even? (ipair (1 (ipair 3 x)))))
(test-error (iany even? (ipair (1 (ipair 3 x)))))
(test-error (ifind even? (ipair 1 (ipair 3 'x))))
(test-error (iany even? (ipair 1 (ipair 3 'x))))
(test 4 (ifind even? (iq 3 1 4 1 5 9)))
(test (iq -8 -5 0 0) (ifind-tail even? (iq 3 1 37 -8 -5 0 0)))
(test (iq 2 18) (itake-while even? (iq 2 18 3 10 22 9)))
Expand All @@ -287,7 +291,7 @@
(test #t (iany < (iq 3 1 4 1 5) (iq 2 7 1 8 2)))
(test #t (ievery integer? (iq 1 2 3 4 5)))
(test #f (ievery integer? (iq 1 2 3 4.5 5)))
(test #t (ievery < (iq 1 2 3) (iq 4 5 6)))
(test #t (ievery (lambda (a b) (< a b)) (iq 1 2 3) (iq 4 5 6)))
(test 2 (ilist-index even? (iq 3 1 4 1 5 9)))
(test 1 (ilist-index < (iq 3 1 4 1 5 9 2 5 6) (iq 2 7 1 8 2)))
(test #f (ilist-index = (iq 3 1 4 1 5 9 2 5 6) (iq 2 7 1 8 2)))
Expand Down
2 changes: 1 addition & 1 deletion ilists/ilists.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(import (only chicken
include define-record-type define-record-printer error))
(export iq)
(export ipair ilist xipair ipair* make-ilist ilist-tabulate iiota)
(export ipair ilist xipair ipair* make-ilist ilist-copy ilist-tabulate iiota)
(export ipair?)
(export proper-ilist? ilist? dotted-ilist? not-ipair? null-ilist? ilist=)
(export icar icdr ilist-ref)
Expand Down
2 changes: 1 addition & 1 deletion ilists/ilists.sld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(define-library (srfi-116)
(import (scheme base))
(export iq)
(export ipair ilist xipair ipair* make-ilist ilist-tabulate iiota)
(export ipair ilist xipair ipair* make-ilist ilist-copy ilist-tabulate iiota)
(export ipair?)
(export proper-ilist? ilist? dotted-ilist? not-ipair? null-ilist? ilist=)
(export icar icdr ilist-ref)
Expand Down