Band
Band[x, y]
Performs a bitwise AND operation on two non-negative numbers x and y.
- Returns a
Number.
Band[12, 10]; (* => 8 *)
Block
Block[expr1, expr2, ...]
Executes a sequence of expressions within an isolated, temporary scope and returns the value of the final expression. A trailing comma after the last argument is allowed.
Variables created or shadowed with Let inside a Block are strictly local to that block and do not affect the surrounding environment.
- Returns the result of the last expression. If no arguments are provided, returns
Unit[].
Let[x, 2];
Print[x]; (* => 2 *)
Block[
Let[x, 10],
Print[x] (* => 10 *)
];
Print[x]; (* => 2 *)
(* Return value example *)
Let[result, Block[
Let[{ a, b }, { 5, 3 }],
Add[a, b]
]];
Print[result]; (* => 8 *)
(* Trailing comma *)
Block[1, 2, 3,]; (* => 3 *)
Block vs. List
Expressions evaluated inside a List literal execute in the current scope. Any variable assignments made there will persist outside the list.
Let[a, 0];
Print[{ Let[b, 10], Let[a, Add[b, b]] }]; (* => {(), ()} *)
Print[{ a, b }]; (* => {20.0, 10.0} *)
Bor
Bor[x, y]
Performs a bitwise OR operation on two non-negative numbers x and y.
- Returns a
Number.
Bor[12, 10]; (* => 14 *)
Bxor
Bxor[x, y]
Performs a bitwise XOR operation on two non-negative numbers x and y.
- Returns a
Number.
Bxor[12, 10]; (* => 6 *)