1
0
Fork
You've already forked chatgpt-popbob
0
generated from LinuxPropaganda/phtui
Everything necessary to use the popbob "porgramming language" with openAI's chatGPT
Find a file
2022年12月08日 21:22:11 +00:00
LICENSE Initial commit 2022年12月08日 21:07:24 +00:00
prompt.txt Add 'prompt.txt' 2022年12月08日 21:21:51 +00:00
README.md Update 'README.md' 2022年12月08日 21:22:11 +00:00

popbob fictional language

A fake programming language which is emulated by OpenAI's ChatGPT

Video about this

Using Popbob

Start chatGPT and paste the prompt, then just type code as a message and send it to run

Here's the docs (the same you will feed to the AI)

The popbob programming language

Overview

There are only four types of "objects" in popbob:

  • Constants, such as strings ("this is a constant string"), numbers (12, 1.4), booleans (True, False), or lists of variables ((1, 2, 3, "pop"))
  • Variables, which are just names that correspond to some value
  • Functions, which will be discussed in focus later
  • Codeblocks, which is popbob code enclosed in curly braces {like this}

Comments are identified by a double slash (// like this)

Functions

Popbob works with funcitons. Every action you can take is done through functions.

  • To call a funciton, it's sufficient to write funciton_name(args, separated, by, commas)

  • To define a function, type

def funcion_name(expected, args, separated, by, commas) {
...code...
return value
}

Returning a value is optional, and if omitted a function will always return False

Built-in funcitons

There are some built-in functions:

  • print(string_or_variable): display string_or_variable in the terminal

  • let(name, value): assign value value to name variable, which is created if not existing. value can also be a list of values enclosed in brackets and separated with commas, ("like", "this"), in which case name will be a variable list

  • math(operator, var1, var2, var3): store in var3 the result of the operation defined by operator (sum +, subtraction -, division /, multiplication *, modulo %) between var1 and var2. var3 is optional, if it is not given, math will return the result of the operation.

  • while(condition, code): run code (which is a codeblock) repeating it as long as condition evaluates to True.

  • concat(var1, var2): will return the result of the concatenation of var2 to var1, if they are numbers they'll be summed. Example concat("hello ", "world") will return "hello world"; concat((1, 2, 3), (1)) will return (1, 2, 3, 1); concat(1, 4) will return 5

Condition Evaluation

Conditions are evaluated to booleans following this rules:

condition will evaluate to True if:

  • it has value (i.e. is a non-empty string or a nonzero number)
  • is a True boolean constant or variable
  • is a list of length nonzero
  • is a true comparison of two numbers (as in a > b, a == b, a <= b)
  • is a true equality of two values (as in a == "content", a == b) else it'll evaluate to False

Note that before any evaluation every function call must be run and replaced by it's return value

Example code:

// calling the built-in print function
print("Hello, world!")
// defining a function
def say_hello(name) {
 print(concat("Hello, ", name))
}
// calling the say_hello function
say_hello("popbob")
// using the let function to create and assign a variable
let(greeting, "Hi there")
print(greeting)
// using the math function
let(x, 5)
let(y, 3)
let(z, math("+", x, y))
print(z) // expected output: 8
// using the while function
let(count, 0)
while(count < 5, {
 print(count)
 math("+", count, 1, count)
})

Expected output:

Hello, world!
Hello, popbob
Hi there
8
0
1
2
3
4