# SlotSequence (##) form analogous to #[[ ;; n]]

I'm aware that this may be closed as offtopic but there are people around with "offtopic" knowledge :)

So, in List context we can: #[[n ;; ]] and #[[ ;; n]], but we can't do this in context of Sequence. Only ##n is available.

One may do

f[n_] := Unevaluated[##][[;; n]] &
f[2][1, 2, 3, 4]

Sequence[1, 2]


but it is not what I'm looking for.

It is very often when I would like to use it. Of course there are no problems with workarounds. I'm just curious.

p.s. Syntax is an issue for sure, I thought something like ###2 could stand for this but ### is automatically interpreted as ##1 #1.

• Just a note, f[1][1] won't work. Even more minor: f[1][1, 2, 3] gives Sequence[1], whereas ##3 &[1, 2, 3] gives 3. Oh well it would be nice to see an answer/"response" :). – Jacob Akkerboom Mar 21 '14 at 12:24
• @JacobAkkerboom good points. :) – Kuba Mar 21 '14 at 12:29
• I think it could be connected to the reason there is HoldFirst and HoldRest, but no HoldMost and HoldLast. Obviously not quite the same, but perhaps related. – b3m2a1 Jan 11 '18 at 8:50

seqChopper[seq_Sequence, span_Span] := Sequence @@ ((List@seq)[[span]])

SetAttributes[seqChopper, SequenceHold]

seqChopper[Sequence[1, 2, 3, 4, 5], 2 ;;]
seqChopper[Sequence[1, 2, 3, 4, 5], 2 ;; -2]
seqChopper[Sequence[1, 2, 3, 4, 5], -2 ;; 1 ;; -2]

(*
Sequence[2, 3, 4, 5]
Sequence[2, 3, 4]
Sequence[4, 2]
*)

• f[n_] := Unevaluated[##][[n]] & will do too. What I'm interested in is rather "why" there is nothing built-in than w workaround. +1 for SequenceHold I've not seen it for a while., – Kuba Mar 21 '14 at 10:16