Browse Source

Explain // operator

David Peter 2 years ago
parent
commit
875b5bfdbe
2 changed files with 8 additions and 2 deletions
  1. 4 1
      book/src/example-numbat_syntax.md
  2. 4 1
      examples/numbat_syntax.nbt

+ 4 - 1
book/src/example-numbat_syntax.md

@@ -50,7 +50,10 @@ mod(17, 4)        # Modulo
 3 in to cm        # Unit conversion with the 'to' keyword
 3 in to cm        # Unit conversion with the 'to' keyword
 
 
 cos(pi/3 + pi)    # Call mathematical functions
 cos(pi/3 + pi)    # Call mathematical functions
-pi/3 + pi // cos  # same as above, useful in REPL
+pi/3 + pi // cos  # Same, 'arg // f' is equivalent to 'f(arg)'
+                  # The '//' operator has the lowest precedence
+                  # which makes it very useful for interactive
+                  # terminals (press up-arrow, and add '// f')
 
 
 # 4. Variable definitions
 # 4. Variable definitions
 
 

+ 4 - 1
examples/numbat_syntax.nbt

@@ -45,7 +45,10 @@ mod(17, 4)        # Modulo
 3 in to cm        # Unit conversion with the 'to' keyword
 3 in to cm        # Unit conversion with the 'to' keyword
 
 
 cos(pi/3 + pi)    # Call mathematical functions
 cos(pi/3 + pi)    # Call mathematical functions
-pi/3 + pi // cos  # same as above, useful in REPL
+pi/3 + pi // cos  # Same, 'arg // f' is equivalent to 'f(arg)'
+                  # The '//' operator has the lowest precedence
+                  # which makes it very useful for interactive
+                  # terminals (press up-arrow, and add '// f')
 
 
 # 4. Variable definitions
 # 4. Variable definitions