Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 186

How to remove adjacent date strings in a list?

$
0
0

Given a list as

list = {"2018-9-1",1,2,3,"2018-9-2","2018-9-3",4,5,6,"2018-9-5",7,8,9,"2018-9-6","2018-9-7",10,11,12,"2018-9-8",13,14,15,"2018-9-9",16,17,18}

or

list = {"2018-9-1","a","b","c","2018-9-2","2018-9-3","d","e","f","2018-9-5","h","i","j","2018-9-6","2018-9-7","k","l","m","2018-9-8","n","o","p","2018-9-9","q","r","s"}

how can adjacent date strings being pruned to get this result?

{"2018-9-1",1,2,3,"2018-9-3",4,5,6,"2018-9-5",7,8,9,"2018-9-7",10,11,12,"2018-9-8",13,14,15,"2018-9-9",16,17,18}

or

{"2018-9-1","a","b","c","2018-9-3","d","e","f","2018-9-5","h","i","j","2018-9-7","k","l","m","2018-9-8","n","o","p","2018-9-9","q","r","s"}

such that the function Partition could be applied properly.Thanks!


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>