From 381ec5920d9ebeb335963778dec182268819e718 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 30 Mar 2022 14:05:57 -0400 Subject: Now demanding mandatory loop names, instead of using default "again" name. --- stdlib/source/documentation/lux.lux | 13 ++++++------- stdlib/source/documentation/lux/control/pipe.lux | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'stdlib/source/documentation') diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index be907a73d..5dbef4fac 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -535,8 +535,8 @@ [(def: .public (range enum from to) (All (_ a) (-> (Enum a) a a (List a))) (let [(open "[0]") enum] - (loop [end to - output {.#End}] + (loop (again [end to + output {.#End}]) (cond (< end from) (again (pred end) {.#Item end output}) @@ -679,15 +679,14 @@ (documentation: /.loop (format "Allows arbitrary looping, using the 'again' form to re-start the loop." \n "Can be used in monadic code to create monadic loops.") - [(loop [count +0 - x init] + [(loop (again [count +0 + x init]) (if (< +10 count) (again (++ count) (f x)) x))] ["Loops can also be given custom names." - (loop my_loop - [count +0 - x init] + (loop (my_loop [count +0 + x init]) (if (< +10 count) (my_loop (++ count) (f x)) x))]) diff --git a/stdlib/source/documentation/lux/control/pipe.lux b/stdlib/source/documentation/lux/control/pipe.lux index 4326a6d49..ae6c1e740 100644 --- a/stdlib/source/documentation/lux/control/pipe.lux +++ b/stdlib/source/documentation/lux/control/pipe.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" let cond if loop exec case} + [lux {"-" let cond if exec case} ["$" documentation {"+" documentation:}] [data [text {"+" \n} @@ -51,12 +51,12 @@ (when [n.even?] [(n.* 2)])))]) -(documentation: /.loop - (format "Loops for pipes." +(documentation: /.while + (format "While loops for pipes." \n "Both the testing and calculating steps are pipes and must be given inside tuples.") [(|> +1 - (loop [(i.< +10)] - [++]))]) + (while [(i.< +10)] + [++]))]) (documentation: /.do (format "Monadic pipes." @@ -110,7 +110,7 @@ ..cond ..if ..when - ..loop + ..while ..do ..exec ..tuple -- cgit v1.2.3