瀏覽代碼

Explain // operator

David Peter 2 年之前
父節點
當前提交
875b5bfdbe
共有 2 個文件被更改,包括 8 次插入2 次删除
  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