Brainlove

From Esolang
Jump to: navigation, search

Brainlove is another extension of the brainfuck language.

Description

Brainlove adds a few more commands to brainfuck in order to make it easier to program in.

Commands

(Assuming ptr is a pointer to a char array and str is a char variable.)

Command C translation
>
++ptr;
<
--ptr;
+
++(*ptr);
-
--(*ptr);
.
putchar(*ptr);
,
*ptr = getchar();
[
while(*ptr) {
]
}
(
while(!*ptr) { /* loop while *ptr == 0 */
)
}
~
break; /* break from the most inner loop */
$
str = *ptr; /* store *ptr in storage, taken from Extended Brainfuck Type I */
!
*ptr = str; /* return from storage, taken from Extended Brainfuck Type I */

Examples

Not function (0 becomes 1 and 1 becomes 0)

-[++~]

if(value != 0) {STUFF}

[STUFF~]

if(value == 0) {STUFF}

(STUFF~)

Swap two values who are next to each other (uses one extra cell)

$>>!<$<!>>$<!>