From e2b07a5fd0bbaad232c717fb90a31d6c61d72bd4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 14 Jul 2022 20:06:50 -0400 Subject: Try to include previous variable definitions in REPL links --- docs/doc/block.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/doc/block.html') diff --git a/docs/doc/block.html b/docs/doc/block.html index ec9e4ed9..cfffe895 100644 --- a/docs/doc/block.html +++ b/docs/doc/block.html @@ -176,7 +176,7 @@

Unlike these assignments, the header also constrains what inputs the block can take: a monadic 1-modifier like the one above can't take a right operand or left argument, so its body can't contain 𝔾 or 𝕨. Calling it with a left argument, or a right argument that isn't a two-element list, will result in an error.

Destructuring

Arguments and operands allow destructuring like assignment does. While assignment only tolerates lists of variables, header destructuring also allows constants. For the header to match, the argument must share the given structure, including the constants where they appear.

-↗️
    Destruct  { 𝕊 a1b,·,2: ab }
+↗️
    Destruct  { 𝕊 a1b,·,2: ab }
     Destruct       517,π,2
 ⟨ 5 7 ⟩
 
@@ -219,12 +219,12 @@ ⟨ 2 4 ⟩

If no header is compatible, the call results in an error.

-↗️
    3 CaseAdd 3
+↗️
    3 CaseAdd 3
 Error: No header matched arguments
 

Case headers

A special rule allows for convenient case-matching syntax for one-argument functions. In any function header with one argument, the function name can be omitted as long as the argument is not a plain identifier—it must be 𝕩 or a compound value like a list to distinguish it from an immediate block label.

-↗️
    Test  {
+↗️
    Test  {
       "abc": "string" ;
       2,b: 𝕩       ;
       5:     "number" ;
@@ -236,7 +236,7 @@
 

These case-style headers function exactly the same as if they were preceded by 𝕊, and can be mixed with other kinds of headers.

Predicates

Destructuring with a header is limited, as it can only match a particular structure or value exactly—not, for example, a range of lengths. A predicate, written with ?, allows you to test an arbitrary property before evaluating the rest of the body, and also serves as a limited kind of control flow. It can be thought of as an extension to a header. So the following function requires the argument to have two elements and for the first to be less than the second before using the first body. Otherwise it moves to the next body, which is unconditional.

-↗️
    CheckPair  { 𝕊a,b: a<b? "ok" ; "not ok" }
+↗️
    CheckPair  { 𝕊a,b: a<b? "ok" ; "not ok" }
 
     CheckPair 3,8    # Fails destructuring
 "ok"
-- 
cgit v1.2.3