键盘快捷键

使用 跳转章节

使用 S/ 在本书内搜索

使用 ? 显示帮助页面

使用 Esc 隐藏帮助页面

Delete

The Delete function is used to remove the key-value pair corresponding to a specified key from an object.

Parameters

The Delete function accepts two parameters: the fist parameter is an object, and the second parameter is a string representing the name of the key to be deleted.

Return Value

The Delete function returns a new Object with the specified key-value pair removed.

Examples

Let[o, Object[Obj, {{"A", 1}, {"B", 2}}]];
Has[o, "B"]; (* => #t *)

Let[o1, Delete[o, "B"]];
Has[o1, "B"]; (* => #f *)
Has[o, "B"]; (* => #t *)

Div

The Div function calculates the quotient of two numbers, equivalent to the mathematical calculation of for Div[a, b].

Parameters

The Div function requires exactly two parameters, both of which must be numeric values.

Return Value

The Div function returns a numeric value.

If the divisor is zero, the Div function will throw an error and will not return any value.

Examples

Div[10, 3];  (* => 3.33333333333333 *)
Div[-2, 7];  (* => -0.285714285714286 *)
Div[4, 2];   (* => 2 *)
Div[7, 0];   (* Error! *)
Div[4];      (* Error! *)

Do

The Do function is used to create a loop, similar to a for-in loop in other languages, to iterate over a list of elements.

Parameters

The Do function accepts three parameters: the first parameter is the loop body, which specifies the code to be executed in each iteration, the second parameter is a symbol, representing the loop variable, used to reference the current element in the loop body, and the third parameter is a list, representing the content to be iterated.

Return Value

The Do function does not return any value, its purpose is to execute the code in the loop body.

Examples

Let[lst, {1, 2, "a", {4}, 5}];
Let[res, ""];
Do[Let[res,
    Concat[res, ToString[e]]],
  e, lst];
Print[res]; (* 12"a"{4}5 *)