SpeechProg
Jump to navigation
Jump to search
SpeechProg is a esolang by Mihai Popa. You use natural language for programming.
Syntax
Comments are done with a hash, but unit tests exercising this code are done with a greater-than sign.
Examples
Hello, world!
On "Say Hello, world!", reply with "Hello, world!" # This can be tested > Say Hello, world!: Hello, world! # This can be created within SpeechProg > Say Hello: Hello, nice to meet you!
XKCD Random Number
On "XKCD", reply with "4" > XKCD: 4
Count from 1 to 10
On "Count me!": Set X to 1 Loop from this until the end Reply with X then a space Set X to the evaluation of X plus 1 # "Set X to the evaluation of X + 1" is also the same If X is 11, then stop the loop > Count me!: 1 2 3 4 5 6 7 8 9 10 Done. > Count me!
Say if a number is a perfect square
On "Is X a perfect square?": Set S to the square root of X Set R to the floor of the value of S Set C to the evaluation of S minus R If C is zero, then reply with "Yes!" But if C is not zero, then reply with "No!" > Is 16 a perfect square?: Yes! > Is 25 a perfect square?: Yes! > Is 30 a perfect square?: No! > Is 60 a perfect square? > Is 49 a perfect square?
Square root and cube root of pi and e
On "Square root of pi": Set P to the square root of pi # It's the same as this: # Set P to the value of pi # Set Q to the square root of P Reply with P On "Cube root of pi": Set P to the cube root of pi # It's the same as this: # Set P to the value of pi # Set Q to the cube root of P Reply with P On "Square root of e": Set P to the square root of e Reply with P On "Cube root of e": Set P to the cube root of e Reply with P > Square root of pi: 1.772453850905516 > Cube root of pi: 1.464591887561523 > Square root of e: 1.648721270700128 > Cube root of e: 1.395612425086089
e with just pure math
# Calculates e with just pure math. # Mihai Popa, accuracy is quite modest. On "Calculate e": # First run, which is 1 Set X to 1 # Second run, which is 1 + (1 / 1) Set Y to the evaluation of X divided by X # Sets Z to 2 Set Z to the evaluation of Y plus X # Third run, which is 1 + (1 / (1 * 2)) Set W to the evaluation of Y multiplied by 2 Set A to the evaluation of X divided by W # Sets B to 2.5 Set B to the evaluation of A plus Z # Fourth run, which is 1 + (1 / (1 * 2 * 3)) Set C to the evaluation of W multiplied by 3 Set D to the evaluation of X divided by C # Sets E to 2.666666... Set E to the evaluation of B plus D # Fifth run, which is 1 + (1 / (1 * 2 * 3 * 4)) Set F to the evaluation of C multiplied by 4 Set G to the evaluation of X divided by F # Sets H to 2.708333... Set H to the evaluation of E plus G # Sixth run, which is 1 + (1 / (1 * 2 * 3 * 4 * 5)) Set I to the evaluation of F multiplied by 5 Set J to the evaluation of X divided by I # Sets K to 2.716666... Set K to the evaluation of H plus J # Seventh run, which is 1 + (1 / (1 * 2 * 3 * 4 * 5 * 6)) Set L to the evaluation of I multiplied by 6 Set M to the evaluation of X divided by L # Sets N to 2.718055... Set N to the evaluation of K plus M # Seventh run, which is 1 + (1 / (1 * 2 * 3 * 4 * 5 * 6 * 7)) Set O to the evaluation of L multiplied by 7 Set P to the evaluation of X divided by O # Sets Q to 2.718253... Set Q to the evaluation of N plus P # Eigth run, which is 1 + (1 / (1 * 2 * 3 * 4 * 5 * 6 * 7 * 8)) Set R to the evaluation of O multiplied by 8 Set S to the evaluation of X divided by R # Sets T to 2.718278... Set T to the evaluation of Q plus S Reply with T > Calculate e: 2.71827876984127