Seoul

From Esolang
Jump to navigation Jump to search

Seoul is a language that allows for data storage within a local system. Created in 2019 by threesodas, it was designed to be semi-beginner friendly. It does not have any graphical support.

Syntax

Input/output functionality

Printing
In Seoul, we print a string like this:

sys << "Hello World!"

Seoul uses keywords for what you want to do, such as sys for system.
First, we define "sys", so the computer knows to do something with the system. Then, we use << to tell it to receive something. Finally, we put "My String!" to tell it that it should take "My String!" and put it in sys.
Read input
To read a user input to a variable, you would do something like this:

sys >> [myVar]

Again, we use sys. Then we use >> to tell it to put something from sys into another object, or in this case, myVar.

Variables

Types
str: string
int: integer
dbl: double
boo: bool
arr: array
mem: memory
Set a variable to a value
To set a variable, we use the << from earlier. Every time you reference a variable, its name should be in [square brackets].
You only need to define the type once. Then, if you want to change it, you convert the variable.

str[fruit] << "Apple"
int[money] << 55
boo[gamer] << true

Arrays work a bit differently:

arr[brands] << &"Amazon" &"Google" &"Hershey's"

Convert a variable type
If you want to convert a user input to an integer or something, you do that by converting. Inputs are always strings.
Convert a string to int:

str[input] <int>

Of course, this will not work if the string is not a number.
Convert a string to bool:

str[myVar] <bool>

You get the gist.

Condition statements

If statements
Create an if statement like this:

if condition ?
   sys << "Hello world!"
else condition ?
   sys << "not a gamer..."
else ?
   sys << "goodbye."

Since Seoul does not use {}, you have to indent. However, lines of code have to line up correctly.
This is correct:

if [myBool] != false ?
  sys << "Could not do action."
  sys << "Try again?"
sys << "Hi"

This is incorrect:

if [fruits].has "apple" ?
   sys << "I like apples too!"
      sys << "Don't you?"
sys << "Fruit!"

Condition operators for if statements

Operator Purpose Example
== Equals [money] == 15
!= Does not equal [bool] != true
>> Greater than [money] >> 75
<< Less than [money] << 0
.has Array has specified item [brands].has "Android"
.!has Array does not have specified item [countries].!has "Argentina"
?? Or [candy].has "gum" ?? [candy].has "candy corn"
&& And [candy].has "gum" && [candy].has "candy corn"

Switch statements
You can write a switch statement like this:

switch #expression
  case #condition ?
     sys << "Hello!"
     break ?
  case #condition ?
     sys << "Goodbye."
     break ?

Classes

Define a class like this:

class[myClass] :>
   sys << "In my class, lol!"
<:

Note: variables are global by default. There are no protection keywords.

Methods/functions

Define a function like this:

func[myFunc] return:static,void :>
   sys << "Hi."
<:

There are return keywords. They are the same as C# return keywords.
There are no loops in Seoul, but you can make a loop like this:

func[loop] return:static,void :>
   sys << "I am looping!"
   [loop]()
<:

Ah yes, how could I forget. This is how you reference a function:

[myFunc](return)

Math

Operator Purpose Example
+ Add two things [n]+[m]
++ Increment a variable [n]++
+= Add a number to a variable [n]+=50
- Subtract two things [n]-[m]
-- Decrement a variable [n]--
-= Sub a number from a var [n]-=60
* Times [n]*[m]
/ Divide [n]/[m]

There's also built in functions:

Function Purpose Example
[rand]() Randomly generate a number [rand](0,20)
[cat]() Concatenate two numbers [cat]([n],50) (if n=20 it would be 2050)
[alb]() Do algebraic stuff [alb](modulo:3:9)

Complete syntax

This is complete syntax which you need to make a program work:

class[Program] :>
  func[main] return:arr[args] :>
    
  <:
<: