Solo

From Esolang
Jump to navigation Jump to search

Solo is created by User:A.

Syntax

s scan a number from the console to the accumulator
o output the accumulator to the console
l loop the next byte forever if the accumulator is not 0

Examples

Truth-machine

solo

1-time numeric cat

so

Interpreter in C (solo.h)

#include <stdio.h>
void solo(const char *code)
{
    int acc = 0;
    while(*code != '\0')
    {
        switch(*code)
        {
            case 's':
                scanf("%d", &acc);
                break;
            case 'o':
                printf("%d\n", acc);
                break;
            case 'l':
                if(acc != 0)
                {
                    char charToLoop = *code;
                    while(charToLoop == 'l')
                        charToLoop = *++code;
                    switch(charToLoop)
                    {
                        case 's':
                            while(1) scanf("%d", &acc);
                            break;
                        case 'o':
                            while(1) printf("%d\n", acc);
                            break;
                        default:
                            while(1);
                    }
                }
        }
        ++code;
    }
}