Let l1 be a list of 100 elements. Assume I'm interested in taking several spans from this list, which I wish to have as a single list, say elements 5 through 25, 33 through 55, and 81 through 95.
So I can use span to extract all three spans separately:
p1 = l1[[5;;25]]
p2 = l1[[33;;55]]
p3 = l1[[81;;95]]
I could then combine these into one list. I'm just wondering if there's a simpler way to do that in one step.
I tried these options:
l2 = l1[[5 ;; 25, 33 ;; 55, 81 ;; 95]]
and
l2 = l1[[{5 ;; 25, 33 ;; 55, 81 ;; 95}]]
and
l2 = l1[[5 ;; 25 && 33 ;; 55 && 81 ;; 95]]
None of these worked though. I got different error messages along the lines of:
Part::pspec: "Part specification {5;;25,33;;55} is neither a machine-sized integer nor a list of machine-sized integers."
Any suggestions?