« first day (4151 days earlier)      last day (334 days later) » 

12:39 AM
Having trouble searching for this, but I bet there's a question about it somewhere I couldn't find. Is there a tidier way to write something like If[x=="a"||x=="b"||x=="c", blah, bloo] other than maybe Switch[x,"a"|"b"|"c",blah,_,bloo] ?
 
 
2 hours later…
2:40 AM
@MarkS.  what exactly you do not like with `If[x=="a"||x=="b"||x=="c", blah, bloo]` ? is it that you do not want to use || so many times?  I see nothing wrong with it. But one possible way is then to use AnyTrue. something like

x = "a";
test = AnyTrue[{"a", "b", "c"}, x == # &];
If[test, "yes", "no"]
 
3:20 AM
Thanks for the response. What I didn't like is the repetition of x. It can also be avoided by using MemberQ, but AnyTrue is good to remember, too. Both of those are on the long side. I guess I was hoping for something like If[match[x,"a"|"b"|"c"],... for a suitable builtin match
 
4:05 AM
@MarkS. There are MatchQ and StringMatchQ, but frankly I would expect MemberQ win them in some cases. These have different properties for generalised cases or performance; in addition to using Dispatch, there's compiled string pattern caching which may affect performance, and if you are applying your match on large number of items, you probably want to write it as a replacement rule and use Replace instead. So, there isn't one perfect solution that fits all scenarios...
 
 
2 hours later…
6:01 AM
Yes, the rule of thumb in Mathematica is that there are at least 10 different ways to do the same thing :)
 
 
5 hours later…
10:35 AM
Any ideas why different rows span vertically in those two examples?
Grid[{
  {1, 2, Style["A\n\n\nB"]},
  {3, SpanFromLeft, SpanFromAbove},
  {4, 5, SpanFromAbove},
  {6, 7, 8}

  }, Frame -> All]
Grid[{
  {1, SpanFromLeft, Style["A\n\n\nB"]},
  {3, SpanFromLeft, SpanFromAbove},
  {4, 5, SpanFromAbove},
  {6, 7, 8}

  }, Frame -> All]
I want to keep the 2nd row stretched but with missing 2 in the first row.
 

« first day (4151 days earlier)      last day (334 days later) »