We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

COSbasic

From Esolang
Jump to navigation Jump to search

COSbasic is very similar to languages like TI-84 basic and Batchs' syntax but much more compact. Codes are stored with one digit names and variables are stored with one digit names as well. Values are all Boolean (I plan to change that in the future but it's simplest currently).

Syntax

Code Description
;A Add A to the top of program stack and run it.
;A% Replace currently running code with A and run A.
1/0 set current output to 1 or 0
A set current output to value of variable A
' set output to user input.
[ If
] Then
. End (has to go after code proceeding "Then")
< current output (treated as a variable)
^A set variable A to current output
@A show value of variable A
1^A/This says @A/ says "This says @A/
1^A\This says @A\ says "This says 1"
!A hides @A and/or \example @A\ (whichever ones farther down in the terminal)
!/string/ hides /string/ in the terminal
!< hides the last thing in the terminal
0[ABC]1.^X set output to 0; If A or B or C Then set output to 1 End; set X to output.

Macros

Code Description
run A runs code A
ren A M renames code A to M
set P 0 sets variable P to 0
sec H prompts you to input new code to set code H

Examples

TR latch? (toggle/reset)

SEC A

[1],\A = @A\;B!A;A%.

SEC B

0['],1[A],0.^A

RUN A

X = A xor B

SEC X

0[AB],1[A],[B],0.^X

RUN X