This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from jitwit/rnrs-list
add list functions to rnrs.ss
- Loading branch information
Showing
14 changed files
with
318 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test assoc) | ||
(export do-test) | ||
(import (rnrs) | ||
(rnrs mutable-pairs)) | ||
|
||
(define alist | ||
`((2 . a) (3 . b))) | ||
|
||
(define (do-test) | ||
(set-cdr! (assoc 3 alist) 'c) | ||
(and (equal? (assoc '(a) '(((a) . a) (-1 . b))) | ||
'((a) . a)) | ||
(not (assoc '(a) '(((b) . b) (a . c)))) | ||
(equal? alist | ||
`((2 . a) (3 . c)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test assq) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(and (equal? '(b . 2) | ||
(assq 'b '((a . 1) (b . 2)))) | ||
(eq? 2 (cdr (assq 'b '((a . 1) (b . 2))))) | ||
(not (assq 'c '((a . 1) (b . 2))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test even) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(and (even? 0) | ||
(even? 2) | ||
(even? -2) | ||
(not (even? -1)) | ||
(not (even? 3))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test filter) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(and (equal? (filter (lambda (x) (and (> x 0) (< x 10))) | ||
'(-5 15 3 14 -20 6 0 -9)) | ||
'(3 6)) | ||
(equal? (filter odd? (iota 5)) | ||
'(1 3))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test find) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(and (eq? 3 (find odd? '(2 3 5 7 11))) | ||
(eq? 2 (find even? '(2 3 5 7 11))) | ||
(not (find even? '(3 5 7 11))) | ||
(not (find (lambda (x) (not x)) '(2 3 #f 7 11)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test iota) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(and (equal? '(0 1 2) (iota 3)) | ||
(null? (iota 0))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test odd) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(and (not (odd? 0)) | ||
(not (odd? 2)) | ||
(not (odd? -2)) | ||
(odd? -1) | ||
(odd? 3)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test remove) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(equal? (remove '(b) '((a) (b) (c))) | ||
'((a) (c))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
;; Copyright 2020 Google LLC | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the License); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
;; | ||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
;; | ||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an AS IS BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
|
||
(library (test remp) | ||
(export do-test) | ||
(import (rnrs)) | ||
|
||
(define (do-test) | ||
(and (equal? (remp odd? '(1 2 3 4)) | ||
'(2 4)) | ||
(equal? (remp (lambda (x) (and (> x 0) (< x 10))) | ||
'(-5 15 3 14 -20 6 0 -9)) | ||
'(-5 15 14 -20 0 -9))))) |
Oops, something went wrong.