diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/control/pipe.lux | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 66d3f2a06..b194d6749 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -27,21 +27,11 @@ (syntax: .public (new> [start <code>.any body body^ prev <code>.any]) - {#.doc (example "Ignores the piped argument, and begins a new pipe." - (n.= 1 - (|> 20 - (n.* 3) - (n.+ 4) - (new> 0 [inc]))))} (in (list (` (|> (~ start) (~+ body)))))) (syntax: .public (let> [binding <code>.any body <code>.any prev <code>.any]) - {#.doc (example "Gives a name to the piped-argument, within the given expression." - (n.= 10 - (|> 5 - (let> x (n.+ x x)))))} (in (list (` (let [(~ binding) (~ prev)] (~ body)))))) @@ -55,12 +45,6 @@ else body^ _ _reversed_ branches (<>.some (<>.and body^ body^))]) - {#.doc (example "Branching for pipes." - "Both the tests and the bodies are piped-code, and must be given inside a tuple." - (|> +5 - (cond> [i.even?] [(i.* +2)] - [i.odd?] [(i.* +3)] - [(new> -1 [])])))} (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] (cond (~+ (do list.monad @@ -73,14 +57,6 @@ then body^ else body^ prev <code>.any]) - {#.doc (example "If-branching." - (same? (if (n.even? sample) - "even" - "odd") - (|> sample - (if> [n.even?] - [(new> "even" [])] - [(new> "odd" [])]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [(~+ else)] (~ prev)))))) @@ -88,13 +64,6 @@ (syntax: .public (when> [test body^ then body^ prev <code>.any]) - {#.doc (example "Only execute the body when the test passes." - (same? (if (n.even? sample) - (n.* 2 sample) - sample) - (|> sample - (when> [n.even?] - [(n.* 2)]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [] (~ prev)))))) @@ -102,11 +71,6 @@ (syntax: .public (loop> [test body^ then body^ prev <code>.any]) - {#.doc (example "Loops for pipes." - "Both the testing and calculating steps are pipes and must be given inside tuples." - (|> +1 - (loop> [(i.< +10)] - [inc])))} (with_identifiers [g!temp] (in (list (` (loop [(~ g!temp) (~ prev)] (if (|> (~ g!temp) (~+ test)) @@ -116,13 +80,6 @@ (syntax: .public (do> [monad <code>.any steps (<>.some body^) prev <code>.any]) - {#.doc (example "Monadic pipes." - "Each steps in the monadic computation is a pipe and must be given inside a tuple." - (|> +5 - (do> identity.monad - [(i.* +3)] - [(i.+ +4)] - [inc])))} (with_identifiers [g!temp] (case (list.reversed steps) (^ (list& last_step prev_steps)) @@ -139,11 +96,6 @@ (syntax: .public (exec> [body body^ prev <code>.any]) - {#.doc (example "Non-updating pipes." - "Will generate piped computations, but their results will not be used in the larger scope." - (|> +5 - (exec> [.nat %n log!]) - (i.* +10)))} (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] (exec (|> (~ g!temp) (~+ body)) @@ -151,13 +103,6 @@ (syntax: .public (tuple> [paths (<>.many body^) prev <code>.any]) - {#.doc (example "Parallel branching for pipes." - "Allows to run multiple pipelines for a value and gives you a tuple of the outputs." - (|> +5 - (tuple> [(i.* +10)] - [dec (i./ +2)] - [Int/encode])) - "Will become: [+50 +2 '+5']")} (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body)))) @@ -165,20 +110,6 @@ (syntax: .public (case> [branches (<>.many (<>.and <code>.any <code>.any)) prev <code>.any]) - {#.doc (example "Pattern-matching for pipes." - "The bodies of each branch are NOT pipes; just regular values." - (|> +5 - (case> +0 "zero" - +1 "one" - +2 "two" - +3 "three" - +4 "four" - +5 "five" - +6 "six" - +7 "seven" - +8 "eight" - +9 "nine" - _ "???")))} (in (list (` (case (~ prev) (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body)) branches)))))))) |