Explorar el Código

Explain // operator

David Peter hace 2 años
padre
commit
875b5bfdbe
Se han modificado 2 ficheros con 8 adiciones y 2 borrados
  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
 
 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 - 1
examples/numbat_syntax.nbt

@@ -45,7 +45,10 @@ mod(17, 4)        # Modulo
 3 in to cm        # Unit conversion with the 'to' keyword
 
 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