From 18b36cc11c208c18422a9327abd52861c165d5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Tue, 6 Dec 2022 18:03:14 -0300 Subject: Reduce iterators with optional and many --- parser.lisp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'parser.lisp') diff --git a/parser.lisp b/parser.lisp index 2da9975..989938b 100644 --- a/parser.lisp +++ b/parser.lisp @@ -84,15 +84,9 @@ (defun optional (p) (either p nothing)) -(defun zero-or-more (p) - (either (comp ((x p) - (xs (zero-or-more p))) - (cons x xs)) - nothing)) - -(defun one-or-more (p) +(defun many (p) (comp ((x p) - (xs (zero-or-more p))) + (xs (optional (many p)))) (cons x xs))) (defun separated-list (p separator) -- cgit v1.2.3