From cd57f867069c4e86a9c02682ddec27baa21152ac Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 31 Dec 2025 21:11:15 +0000 Subject: utils: Require arity for mapn. With an empty list, mapn cannot know the number of values proc would return. mapn therefore needs to know the arity of proc. To provide for existing callers of mapn, we add a map2 function variant. Finally, we add a test case testing mapn on an empty list. --- tests/utils.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/utils.scm b/tests/utils.scm index 50c3396..d786d02 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021, 2022, 2023 Arun Isaac +;;; Copyright © 2021, 2022, 2023, 2025 Arun Isaac ;;; ;;; This file is part of ccwl. ;;; @@ -194,7 +194,17 @@ (let ((squares cubes (mapn (lambda (n) (values (expt n 2) (expt n 3))) - (iota 5)))) + (iota 5) + 2))) + (list squares cubes))) + +(test-equal "mapn on an empty list" + '(() ()) + (let ((squares cubes (mapn (lambda (n) + (values (expt n 2) + (expt n 3))) + '() + 2))) (list squares cubes))) (test-equal "foldn" -- cgit 1.4.1