0
$\begingroup$

Why can't I use this

Where[{iw, ih} = ImageDimensions[i], ...]

instead of this

Where[dim = ImageDimensions[i], iw = dim[[1]], ih = dim[[2]], ...]
$\endgroup$
3
  • $\begingroup$ Excuse me, why the down-vote? This is a good question that might expose a limitation of the core language, perhaps you don't care for language design? $\endgroup$
    – M.R.
    Commented Mar 4, 2015 at 1:05
  • 1
    $\begingroup$ It has very little value in my opinion. But I reversed my down-vote. $\endgroup$
    – m_goldberg
    Commented Mar 4, 2015 at 1:10
  • $\begingroup$ possible duplicate of A smarter nested With? $\endgroup$ Commented Mar 4, 2015 at 1:57

1 Answer 1

2
$\begingroup$

Presumably you are referring to Where from the "GeneralUtilities"` package.

You can see the definition for yourself:

Attributes[Where] = {HoldAll}

Where[expr_] := expr

Where[x_List, expr_] := With[x, expr]

Where[x_, expr_] := With[{x}, expr]

Where[x_, rest__, expr_] := Where[x, Where[rest, expr]]

Where[s : Verbatim[Set][x_List, y_], rest___, expr_] := 
  With[{x2 = Quiet[Replace[Hold[x], z_Symbol :> z_, {2}]]},
    Replace[y, {HoldPattern @@ x2 :> Where[rest, expr], _ -> $Failed}]]

If it is not written as you would like use this for inspiration and write your own. :-)

$\endgroup$
1
  • 1
    $\begingroup$ Ah, that casts some real light on the question. I still think the question is badly posed. $\endgroup$
    – m_goldberg
    Commented Mar 4, 2015 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.