-
Notifications
You must be signed in to change notification settings - Fork 12
/
for-each.less
80 lines (68 loc) · 1.39 KB
/
for-each.less
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@fruit: banana, apple, pear, potato, carrot, peach;
@2d-list: a b c, e f g;
#for-each-fruit {
.for-each(@value in @fruit) {
value: @value;
}
}
#for-each-index-fruit {
.for-each(@value, @index in @fruit) {
@{index}: @value;
}
}
#for-each-inline-list {
.for-each(@x in @inline-list: a b c) {
r: @x of @inline-list;
}
}
#for-each-nested {
.for-each(@x in @2d-list) {
.for-each(@y in @x) {
r: @y of _inspect(@x);
}
}
}
#for-each-nested-index {
.for-each(@x, @i in @2d-list) {
.for-each(@y, @j in @x) {
@p: @i * 10 + @j;
@{p}: @y;
}
}
}
#for-each-nested-scope {
.for-each(@x, @i in @2d-list) {
outer-@{i}: outer @x;
.for-each(@x, @i in @x) {
inner-@{i}: inner @x;
}
}
}
#for-each-nested-lazy-eval {
.for-each(@x, @i in @2d-list) {
outer-@{i}: @lazy;
.for-each(@x, @j in @x) {
inner-@{j}: @x ~'=' @lazy;
}
@lazy: @x;
}
}
.for-each-guard {
@a: 1 2 3 4 5;
.for-each(@x in @a) when (@x = 2), (@x = 4) {
a+_: @x;
}
@b: 1 a 2 b 3 c 4 d;
.for-each(@x in @b) when (iskeyword(@x)) {
b+_: @x;
}
.for-each(@x in @b) when (isnumber(@x)) {
c+_: @x;
}
}
.for-each {
me: is not a loop;
.for-each {
me: is not a loop too;
}
}