Question: Very often, when using the command line or just programming, you want to express some kind of combination that you end up using a `for` - which is often verbose.

```
for (int i = 0; i<10; ++i)
    std::cout << "img_" << i << std::endl;

for f in *; do echo "$f"; done

```

I always wondered if there is some kind of language made to simplify this case? For example:

```
"mv img_[0~6] imgs"

```

Would translate to

```
mv img_0 imgs
mv img_1 imgs
mv img_2 imgs
mv img_3 imgs
mv img_4 imgs
mv img_5 imgs

```

`img_[0~1][0~1]` could work for `img_00, img_01, img_10, img_11`

`img_[x:0~2][x]` could work for `img_00, img_11, img_22`

Etc. 

I'm not asking for this particular syntax, just if there is any kind of language/feature ever implemented with the purpose of expressing such combinations as easy as possible?

Answer: 
In bash, you can write

```
mv img_{0..5} imgs/

```

which is expanded by the shell to

```
mv img_0 img_1 img_2 img_3 img_4 img_5 imgs/

```

You can also use a character class:

```
mv img_[0-5] imgs/

```

which would only work for those files that already exist and match the expression, while the former expands to all the possibilities even if the files do not exist. The curlies can also pad the expanded number with zeros (`{001..030}`), reverse the order (`{z..a}`) or generate combinations (`{a..z}{0..5}`).
To answer your immediate concern, bash can do some range-based actions on existing files.

```
$ ls
sample1.txt  sample2.txt  sample3.txt  sample4.txt  samples

$ mv sample[1-3].txt samples/

$ ls *
sample4.txt

samples:
sample1.txt  sample2.txt  sample3.txt

```

But there is a bigger trend at play here. [Array programming](http://en.wikipedia.org/wiki/Array_programming) tries to get away from explicit loops. It was really pushed by APL in the beginning and is now common in many mathematical languages like MATLAB or Mathematica. For example, I can add two numerical arrays with a simple

```
c = a + b

```

Likewise, [list comprehension](http://en.wikipedia.org/wiki/List_comprehension) uses set notation to build an array. This is a common feature in many languages today, including Python and Haskell.

```
S = [2 * x for x in range(101) if x ** 2 > 3]

```

Within the realm of shell scripting, I can use [xargs](http://en.wikipedia.org/wiki/Xargs) to execute a command on multiple inputs.

```
hg st | cut -d ' ' -f 2 | xargs rm     # delete my leftovers from Mercurial

```

In the world of databases, [SQL](http://en.wikipedia.org/wiki/SQL) can perform queries and updates on an entire column.

```
select sym from stocks where price < 20.0 order by sym;

```

And lastly, [recursion](http://en.wikipedia.org/wiki/Recursion_%28computer_science%29) obviates loops by defining an entity in terms of itself:

```
fac 0 = 1
fac x = x * fac (x-1)

```

So there are lots of examples where languages have gone away from explicit iterations in favor of declarative structures.