Skip to main content
Became Hot Network Question
Tweeted twitter.com/StackMma/status/1222308554012594182
added 1066 characters in body
Source Link
user13892
  • 9.8k
  • 2
  • 15
  • 44

I have an expr which has List at various levels and I want to display them nicely as a column inside a frame but my problem is that the search for List goes inside things like DateObject to ruin their structure.

Replace[
    expr,
    x_List/;!MatchQ[...[...x...],DateObject[x,__]]:>Framed[Column@x]
    All
]

So how should I define such a Rule?


sampleSample expr:

{1->a,2->b,3->c,4->{5->d,6->e,7->Today},8->Yesterday,9->{10->f,11->{12->Tomorrow,13->g}}}

Current output:

Framed[Column[{1 -> a, 2 -> b, 3 -> c, 4 -> Framed[Column[{5 -> d, 6 -> e, 7 -> DateObject[Framed[Column[{2020, 1, 28}]], "Day", CalendarType -> "Gregorian", DateFormat -> Automatic]}]], 
       8 -> DateObject[Framed[Column[{2020, 1, 27}]], "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 
       9 -> Framed[Column[{10 -> f, 11 -> Framed[Column[{12 -> DateObject[Framed[Column[{2020, 1, 29}]], "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 13 -> g}]]}]]}]]

Desired output:

Framed[Column[{1 -> a, 2 -> b, 3 -> c, 4 -> Framed[Column[{5 -> d, 6 -> e, 7 -> DateObject[{2020, 1, 28}, "Day", CalendarType -> "Gregorian", DateFormat -> Automatic]}]], 
       8 -> DateObject[{2020, 1, 27}, "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 
       9 -> Framed[Column[{10 -> f, 11 -> Framed[Column[{12 -> DateObject[{2020, 1, 29}, "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 13 -> g}]]}]]}]]

I have an expr which has List at various levels and I want to display them nicely as a column inside a frame but my problem is that the search for List goes inside things like DateObject to ruin their structure.

Replace[
    expr,
    x_List/;!MatchQ[...[...x...],DateObject[x,__]]:>Framed[Column@x]
    All
]

So how should I define such a Rule?


sample expr:

{1->a,2->b,3->c,4->{5->d,6->e,7->Today},8->Yesterday,9->{10->f,11->{12->Tomorrow,13->g}}}

I have an expr which has List at various levels and I want to display them nicely as a column inside a frame but my problem is that the search for List goes inside things like DateObject to ruin their structure.

Replace[
    expr,
    x_List/;!MatchQ[...[...x...],DateObject[x,__]]:>Framed[Column@x]
    All
]

So how should I define such a Rule?


Sample expr:

{1->a,2->b,3->c,4->{5->d,6->e,7->Today},8->Yesterday,9->{10->f,11->{12->Tomorrow,13->g}}}

Current output:

Framed[Column[{1 -> a, 2 -> b, 3 -> c, 4 -> Framed[Column[{5 -> d, 6 -> e, 7 -> DateObject[Framed[Column[{2020, 1, 28}]], "Day", CalendarType -> "Gregorian", DateFormat -> Automatic]}]], 
       8 -> DateObject[Framed[Column[{2020, 1, 27}]], "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 
       9 -> Framed[Column[{10 -> f, 11 -> Framed[Column[{12 -> DateObject[Framed[Column[{2020, 1, 29}]], "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 13 -> g}]]}]]}]]

Desired output:

Framed[Column[{1 -> a, 2 -> b, 3 -> c, 4 -> Framed[Column[{5 -> d, 6 -> e, 7 -> DateObject[{2020, 1, 28}, "Day", CalendarType -> "Gregorian", DateFormat -> Automatic]}]], 
       8 -> DateObject[{2020, 1, 27}, "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 
       9 -> Framed[Column[{10 -> f, 11 -> Framed[Column[{12 -> DateObject[{2020, 1, 29}, "Day", CalendarType -> "Gregorian", DateFormat -> Automatic], 13 -> g}]]}]]}]]
added 169 characters in body
Source Link
user13892
  • 9.8k
  • 2
  • 15
  • 44

I have an expr which has List at various levels and I want to display them nicely as a column inside a frame but my problem is that the search for List goes inside things like DateObject to ruin their structure.

Replace[
    expr,
    x_List/;!MatchQ[...[...x...],DateObject[x,__]]:>Framed[Column@x]
    All
]

So how should I define such a Rule?


sample expr:

{1->a,2->b,3->c,4->{5->d,6->e,7->Today},8->Yesterday,9->{10->f,11->{12->Tomorrow,13->g}}}

I have an expr which has List at various levels and I want to display them nicely as a column inside a frame but my problem is that the search for List goes inside things like DateObject to ruin their structure.

Replace[
    expr,
    x_List/;!MatchQ[...[...x...],DateObject[x,__]]:>Framed[Column@x]
    All
]

So how should I define such a Rule?

I have an expr which has List at various levels and I want to display them nicely as a column inside a frame but my problem is that the search for List goes inside things like DateObject to ruin their structure.

Replace[
    expr,
    x_List/;!MatchQ[...[...x...],DateObject[x,__]]:>Framed[Column@x]
    All
]

So how should I define such a Rule?


sample expr:

{1->a,2->b,3->c,4->{5->d,6->e,7->Today},8->Yesterday,9->{10->f,11->{12->Tomorrow,13->g}}}
[Edit removed during grace period]
Source Link
user13892
  • 9.8k
  • 2
  • 15
  • 44
Source Link
user13892
  • 9.8k
  • 2
  • 15
  • 44
Loading