@@ -60,17 +60,26 @@ class With(Builtin):
6060 <dl>
6161
6262 <dt>'With[{$x$=$x0$, $y$=$y0$, ...}, $expr$]'
63- <dd>specifies that all occurrences of the symbols $x$, $y$, ... in $expr$ should be replaced by $x0$, $y0$, ...
63+ <dd>specifies that all occurrences of the symbols $x$, $y$, ... in $expr$ should be replaced by $x0$, $y0$, ...
6464 </dl>
6565
6666 >> n = 10
6767 = 10
68+
69+ Evaluate an expression with x locally set to 5:
6870 >> With[{n = 5}, n ^ 2]
6971 = 25
7072 >> n
7173 = 10
74+
75+ 'With' works even without evaluation:
76+ >> With[{x = a}, (1 + x^2) &]
77+ = 1 + a ^ 2&
78+
79+ Use 'With' to insert values into held expressions
7280 >> With[{x=y}, Hold[x]]
7381 = Hold[y]
82+
7483 >> Table[With[{i=j}, Hold[i]],{j,1,4}]
7584 = {Hold[1], Hold[2], Hold[3], Hold[4]}
7685 >> x=5; With[{x=x}, Hold[x]]
@@ -624,7 +633,7 @@ class BeginPackage(Builtin):
624633 System`Private`$ContextPathStack =
625634 Append[System`Private`$ContextPathStack, $ContextPath];
626635 $ContextPath = {context, "System`"};
627- $Packages = If[MemberQ[System`$Packages,$Context],
636+ $Packages = If[MemberQ[System`$Packages,$Context],
628637 None,
629638 System`$Packages=Join[{$Context}, System`$Packages]];
630639 Protect[System`Private`$ContextPathStack, System`$Packages];
0 commit comments