!English/Examples

From Esolang
Jump to navigation Jump to search

Back to !English

Examples

Hello, world!

Save as: hello.eng

Print "Hello, world!" and a newline

FizzBuzz

Save as: fizzbuzz.eng

Declare x as a integer
For 100 times, using the integer x:
  If x modulo 3 is 0:
    Print "Fizz!" and a newline
  If x modulo 5 is 0:
    Print "Buzz!" and a newline
  If x modulo 15 is 0:
    Print "Fizz Buzz!" and a newline
  Else:
    Print the value of x and a newline

Dice roller

Save as: dice.eng

Declare x as a random number between 1 and 6
Declare y as a random number between 1 and 6
Print both values of x and y and a newline

Truth machine

Save as: truth.eng

Give me x as input
If x is 0:
  Print 0 and a newline
Else:
  While x is 1:
    Print 1 and a newline
    Hold for 200 milliseconds

Cat

Save as: cat.eng

Give me x as input
Print the value of x and a newline

A calculator

Save as: calc.eng

Start of this part: Menu
Print "This is the calculator!" and a new line
Print "Made in the !English programming language!" and a new line
Print "What to do?" and a new line
Print "1. Addition" and a new line
Print "2. Subtraction" and a new line
Print "3. Multiplication" and a new line
Print "4. Division" and a new line
Print "5. Modulo" and a new line
Print "6. Power" and a new line
Give me x as input
If x is 1:
  Jump to the addition part of the code
If x is 2:
  Jump to the subtraction part of the code
If x is 3:
  Jump to the multiplication part of the code
If x is 4:
  Jump to the division part of the code
If x is 5:
  Jump to the modulo part of the code
If x is 6:
  Jump to the power part of the code
End of this part: Menu

Start of this part: Addition
Give me x as input
Give me y as input
Declare z as a addition of x and y
Print the value of z and a newline
End of this part: Addition

Start of this part: Subtraction
Give me x as input
Give me y as input
Declare z as a subtraction of x and y
Print the value of z and a newline
End of this part: Subtraction

Start of this part: Multiplication
Give me x as input
Give me y as input
Declare z as a multiplication of x and y
Print the value of z and a newline
End of this part: Multiplication

Start of this part: Division
Give me x as input
Give me y as input
Declare z as a division of x and y
Print the value of z and a newline
End of this part: Division

Start of this part: Modulo
Give me x as input
Give me y as input
Declare z as a modulo of x and y
Print the value of z and a newline
End of this part: Modulo

Start of this part: Power
Give me x as input
Give me y as input
Declare z as a power of x and y
Print the value of z and a newline
End of this part: Power

Rickrolling (by a webpage)

Save as: rickroll.eng

Start this webpage: https://www.youtube.com/watch?v=dQw4w9WgXcQ

Fake Quine

This one doesn't print all the source code, only the code inside the quotes. Save as: fakequine.eng

Declare x as "Declare x as
Print the value of x and a new line"
Print the value of x and a new line

Cheating Quine

Save as: cheatquine.eng

Print the program's source code

Shell

Save as: shell.eng

Declare x as a string
Print "$" and Give me x as input
If x is "echo" and has a argument called y:
  Print the value of y and a newline
If x is "move" and has 2 arguments, called y and z:
  Move the object y to z
If x is "copy" and has 2 arguments, called y and z:
  Copy the object y to z
If x is "cd" and has a argument called y:
  Put the working folder 1 folder deep
If x is "cd..":
  Put the working folder 1 folder shallow
If x is "make" and has a argument called y:
  Create a new object called y
If x is "rename" and has 2 arguments, called y and z:
  Rename the object y to z
If x is "directory" and has a argument called y:
  Print the directory listing of the folder y
If x is "type" and has a argument called y:
  Read the file y
Else:
  Print "Error!" and a new line

A chatbot that uses GPT-3

Save as: gpt3.eng

Use the GPT-3 API, with the API key "Paste-your-API-key"
Start the client.
Generate text from the prompt "Hello! This is GPT-3!", using the settings:
  max length: 128
  engine: "text-davinci-002"
Print the generated text.

A chatbot that uses GPT-4o

Save as: gpt4o.eng

Use the GPT-4o API, with the API key "Paste-your-API-key"
Start the client.
Generate text from the prompt "Hello!", using GPT-4o, using the settings:
  max length: 128
Print the generated text.

A GUI dialog-box

Save as: gui.eng

Show a dialog-box using the settings:
  title: "Hello, world!"
  content: "Hello, world! This is !English language!"
Hold for 1000 milliseconds
Trap the execution of this program

Basic filesystem functionality (creating new files & deleting files)

Save as: filesys.eng

Create a new file called "Mihai.txt" with the contents "Hello!"
Start the file "Mihai.txt"
Hold for 5000 milliseconds
Delete the file "Mihai.txt"
Create a new file called "Loop.txt"
Declare x as integer
For 100 times, using the integer x:
  While x is less than 50 and greater than 75:
    Write "Alarm!" to the file "Loop.txt" and a newline
  Write "Hiu, this is in !English language!" to the file "Loop.txt" and a newline
Hold for 5000 milliseconds
Start the file "Loop.txt"
Hold for 15000 milliseconds
Delete the file "Loop.txt"

Nested loops

Save as: nestedloops.eng

For 3 times, using the integer x:
  Print the value of x and a newline
  For 5 times, using the integer y:
    Print the value of y and a newline
    For 7 times, using the integer z:
      Print the value of z and a newline

A+B Problem

Save as: aplusbproblem.eng

Give me x as input
Give me y as input
Declare z as a addition of x and y
Print the value of z and a newline

A+B Problem (using functions)

Save as: aplusbproblem_func.eng

Declare a function named "A+B problem" that takes 2 arguments, x and y:
  Declare z as a addition of x and y
  Print the value of z and a newline
End of function declaring
Use a function named "A+B problem" with 2 arguments, "5" and "3"