Preserve Line Numbers

From Esolang
Jump to navigation Jump to search

Preserve Line Numbers is a twin language of Remove Line Numbers also created by User:None1, there is almost no difference, the only difference is that Remove Line Numbers removes all the line numbers but Preserve Line Numbers removes all the text.

What it Can do

Preserve Line Numbers is much less powerful than Remove Line Numbers, because Remove Line Numbers can print anything, but Preserve Line Numbers can only print a sequence of decimal integers starting from 1, separated by line feeds.

But preserve line numbers is also more powerful than Remove Line Numbers, because it has infinite number of quines, but Remove Line Numbers doesn't have any.

Example Programs

Print 1

1 Blah Blah Blah, no matter what this is.

An easier way to print 1

1 

Print integers from 1 to 10

1
2
3
4
5
6
7
8
9
10

Interpreters

C++ as Windows executable (64bit) (faster link)

#include<cstdio>
#include<cstdlib>
char line[1000000];
int Gets(char *line){
	int i=0,flag=0;
	while(1){
		char c=getchar();
		if(c==EOF||c=='\n') line[i]=0;
		if(c==EOF) return EOF;
		if(c=='\n') return 0;
		if(c!=' ') flag=1;
		if(!flag) continue;
		line[i]=c;
		i++;
	}
}
void error(){
	puts("Invalid syntax");
	exit(1);
}
#define gets Gets
int main(){
	int l=0;
	while(1){
		l++;
		int x=-1;
		if(scanf("%d",&x)==EOF) break;
		if(x!=l) error();
		gets(line);
		printf("%d\n",l);
	}
	return 0;
}

See Also