summaryrefslogtreecommitdiff
path: root/test-suite/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-10-08 10:43:59 +0200
committerLudovic Courtès <ludo@gnu.org>2010-10-08 15:25:56 +0200
commita6505cb49c0971671bcdc87eb6abbc3204d94d97 (patch)
tree168ce0275aeb38c10b2eeab4a2bc1293b08b59a7 /test-suite/tests
parent07076c1e61ab05b62979ee01a5220edb308b0750 (diff)
downloadguile-a6505cb49c0971671bcdc87eb6abbc3204d94d97.tar.gz
SRFI-1: Make `fold-right' tail-recursive.
* module/srfi/srfi-1.scm (fold-right): Make tail-recursive. * test-suite/tests/srfi-1.test ("fold-right"): New test prefix.
Diffstat (limited to 'test-suite/tests')
-rw-r--r--test-suite/tests/srfi-1.test22
1 files changed, 22 insertions, 0 deletions
diff --git a/test-suite/tests/srfi-1.test b/test-suite/tests/srfi-1.test
index 8569a3db1..eaad8c961 100644
--- a/test-suite/tests/srfi-1.test
+++ b/test-suite/tests/srfi-1.test
@@ -1266,6 +1266,28 @@
(equal? '((1 2) (3 4) (5 6)) lst))))))
;;
+;; fold-right
+;;
+
+(with-test-prefix "fold-right"
+
+ (pass-if "one list"
+ (equal? (iota 10)
+ (fold-right cons '() (iota 10))))
+
+ (pass-if "two lists"
+ (equal? (zip (iota 10) (map integer->char (iota 10)))
+ (fold-right (lambda (x y z)
+ (cons (list x y) z))
+ '()
+ (iota 10)
+ (map integer->char (iota 10)))))
+
+ (pass-if "tail-recursive"
+ (= 1e6 (fold-right (lambda (x y) (+ 1 y))
+ 0
+ (iota 1e6)))))
+;;
;; unfold
;;