List comprehensions: Difference between revisions
m
→{{header|C}}: 3 syntaxhighlight -> 1 plus comment
(→Insitux: fix breaking changes) |
m (→{{header|C}}: 3 syntaxhighlight -> 1 plus comment) |
||
Line 397:
C doesn't have a built-in syntax for this, but any problem can be solved if you throw enough macros at it:
{{works with|GCC}}
The program below is C11 compliant. For C99 compilers note the change on line 57
for (int i = f + 1; i <= t; i ++) { e = e->nx = listNew(sizeof i, &i); }▼
int i;▼
<syntaxhighlight lang="c">
#include <stdlib.h>
Line 464 ⟶ 455:
List * intRangeList(int f, int t) {
List * l = listNew(sizeof f, &f), * e = l;
for (int i = f + 1; i <= t; i ++) { e = e->nx = listNew(sizeof i, &i); } // C11 compliant
▲//int i;
return l;
}
|