Message Boards Message Boards

0
|
3936 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

List manipulation with DateObject

POSTED BY: Michiel van Mens
2 Replies
Posted 3 years ago

The problem is that each nested list also contains 6 items so the c matches the third sublist.

l6 = Range[36] // Partition[#, 6] &
l6 /. {a_, b_, c_, d_, e_, f_} :> c
(* {13, 14, 15, 16, 17, 18} *)

l5 = Most@l6
l5 /. {a_, b_, c_, d_, e_, f_} :> c
(* {3, 9, 15, 21, 27} *)

To avoid issues like this use more specific patterns

test /. {a_, b_, c_DateObject, d_, e_, f_} :> {a, b, DateObject[c, "Month"], d, e, f}
POSTED BY: Rohit Namjoshi
Posted 3 years ago

Crossposted here.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract