From f371c3702eafdc38b3e1fac77a9388cab25e4751 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 19 Sep 2017 19:16:39 -0400 Subject: - Added "when" function (great for piping). --- stdlib/source/lux.lux | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'stdlib/source/lux.lux') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 641e8693d..6b29d7c42 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -5603,10 +5603,10 @@ (macro: #export (undefined tokens) {#;doc (doc "Meant to be used as a stand-in for functions with undefined implementations." "Undefined expressions will type-check against everything, so they make good dummy implementations." + "However, if an undefined expression is ever evaluated, it will raise a runtime error." (def: (square x) (-> Int Int) - (undefined)) - "If an undefined expression is ever evaluated, it will raise an error.")} + (undefined)))} (case tokens #;Nil (return (list (` (error! "Undefined behavior.")))) @@ -5761,3 +5761,10 @@ _ (#;Left "Wrong syntax for char"))) + +(def: #export (when test f) + (All [a] (-> Bool (-> a a) (-> a a))) + (function [value] + (if test + (f value) + value))) -- cgit v1.2.3