Impulse Programming Language
The Language for Speedy Coding and Speedy Learning Made in only 2200 lines of code!
Our goal is to make Coding Simple and quick, Impulse is a very flexible language which means minimum errors and maximum progress! And even when the errors are scarce, they are easy to understand, meaning even more productivity rather than those StackOverflow Visits!
Variables In Impulse
To Create a Variable use the "var" Keyword, you can also use all mathematical operations.
var age = 12 age + 1 * 1 / 1 ^ 1 - 1
The "var" Keyword can also be used to create lists, and can also hold in functions, if, for, and while statements!
Comparisons in Impulse
Test whether different items are equal, less than, greater than, using "and" and "or" Keywords as well!
1 == 1 1 == 1 and 2 == 2 3 == 2 or 1 == 1 1 == 2
True True True False
Comments in Impulse
Comments are useful pieces of software to use while coding!
#This is a Comment
Strings in Impulse
Strings are important and there are many ways to use them in Impulse! By adding two strings together you can concatenate them. You can multiply strings by putting how many times you wish for the string to repeat.
"This is a String" var test = "String" "String" + "Test" "Hello, " * 3
"This is a String" "String Test" "Hello, Hello, Hello"
If Statements in Impulse
You can put an if statement inside of the var Keyword, or you can make it its own line as well! When using the if statement in its own file, you can have multi-lined statements. The "elif" and "else" Keywords are optional.
One Line If Statement: var age = 18 if age >= 18 then 40 elif age == 17 then 30 else 20 Multi Lined Statement: if 1 + 2 == 3 then "What Do You Know!? Math Works" else "HUH?!?!?!!" end
40 "What Do You Know!? Math Works"
For and While Loops in Impulse
For and While Loops are important parts of any language, the format for the For Loop is similar to the If Statement in Impulse, while the While Loop is similar to the While Loop in Python.
One Line For Statement: for i = 0 to 11 then print(i) Multi Line For Statement: for i = 0 to 11 then print(i) end While Loop: while True then print("123")
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Lists In Impulse
Lists Are an Important Data Structure!
Adding a value to a list is the same thing as appending it. Multiplying two lists together make one list with both of the lists's values. Subtracting from a list removes whatever has that index in the list. Dividing an integer from a list shows you what value is in that index. And there are also append(), extend(), pop(), and choices() functions as well!
var testList = [1, 2, 3] print(list + 4) print(list * [4, 5, 6]) print(list/2) extend(list, [4, 5, 6]) pop(list, 2) append(list, 4) choice(list)
[1, 2, 3, 4] [1, 2, 3, 4, 5, 6] 3 [1, 2, 3, 4, 5, 6] [1, 2] [1, 2, 3, 4] #The Choice Function Returns a Random Value from a List
There are also return, continue, and break features in Impulse. I believe that these are pretty self-explanatory and therefore do not need explaining.
Functions in Impulse
Functions Are An Especially Important Part Every Language. Without Them, You can't really do anything without the language providing you with everything. In Impulse, functions are defined using the "func" Keyword and you show what the function does using an arrow ("->"). There are once again single lined and multi-lined functions.
Single Lined Function: func add(a, b) -> a + b add(1, 2) func greet(name, times) -> "Hello, " * times + name greet("Repl", 3) Multi Lined Function: func age(year) var Yourage = 2020 - year print(Yourage) end age(2007)
3 "Hello, Hello, Hello, Repl" 13
Impulse Built-In Functions
There is no good language with several built-in functions! They save the programmer from wasting a lot of time. Impulse has several great Built-In Functions, and you've already seen some of them!
PI #Will give the Value of PI print(value) #Will print the given value input() #Will ask for an input although cannot have text within, so have a print statement before the input INTinput() #Same as the Input Function but can only receive integers clear() #Clears the Screen cls() #Clears the Screen IsNum(value) #Will check whether the given value is a number and give a boolean response IsStr(value) #Will check whether the given value is a string and give a boolean response IsList(value) #Will check whether the given value is a list and give a boolean response IsFunc(value) #Will check whether the given value is a function and give a boolean response append(list, value) #Will append the value to the list extend(list1, list2) #Will combine the two lists together len(list) #Will return the length of the given list typewrite(value) #Will slow print the value choice(list) #Will return a random value from the given list run("<file name here>") #Will run that file
Side Note: You have to create a .impls file to run. If you are using the multi-line features, then you will have to put the "end" Keyword whenever a for, if, or function ends. And only double quotes (") work in my language, not single quotes ('), but I could try and update that. File Systems are on the Way! The Variable won't Update unless you put the var Keyword next to it. Example:
var age = 12 age = age + 3 #Will Return 15 But age Value will remain 12 var age = 12 var age = age + 3 #Will Return 15 And age Value will change to 15
If you have any questions, comments, or concerns please tell me them, and I will try my best to make Impulse great! Link to the original team project: https://repl.it/@Impulsive/Impulse-Programming-Language#main.py