-
Notifications
You must be signed in to change notification settings - Fork 161
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 #885 from gambiteer/vector-fold
Add vector-fold{-right}, remove string-{any|every}
- Loading branch information
Showing
8 changed files
with
484 additions
and
314 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
(include "#.scm") | ||
|
||
|
||
(check-equal? (vector-fold (lambda (len str) | ||
(max (string-length str) len)) | ||
0 | ||
'#("a b c" "ab" "" "cde")) | ||
5) | ||
|
||
(check-equal? (vector-fold xcons | ||
'() | ||
'#(a b c d)) | ||
'(d c b a)) | ||
(check-equal? (vector-fold (lambda (counter n) | ||
(if (even? n) (+ counter 1) counter)) | ||
0 | ||
'#(0 1 2 3 4)) | ||
3) | ||
|
||
(check-tail-exn type-exception? (lambda () (vector-fold 4 4 '#()))) | ||
(check-tail-exn type-exception? (lambda () (vector-fold xcons 4 '()))) | ||
(check-tail-exn type-exception? (lambda () (vector-fold xcons 4 '#()'()))) | ||
|
||
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-fold))) | ||
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-fold xcons))) | ||
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-fold xcons 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,14 @@ | ||
(include "#.scm") | ||
|
||
(check-equal? (vector-fold-right xcons | ||
'() | ||
'#(a b c d)) | ||
'(a b c d)) | ||
|
||
(check-tail-exn type-exception? (lambda () (vector-fold-right 4 4 '#()))) | ||
(check-tail-exn type-exception? (lambda () (vector-fold-right xcons 4 '()))) | ||
(check-tail-exn type-exception? (lambda () (vector-fold-right xcons 4 '#()'()))) | ||
|
||
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-fold-right))) | ||
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-fold-right xcons))) | ||
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (vector-fold-right xcons 0))) |