Andrew's Programming Language
- This is still a work in progress. It may be changed in the future.
Andrew's Programming Language is a work-in-progress language created by User:Afarnen. It also needs a name (please help; I'm horrible at naming).
Let's create a variable x with a value of 5, you'd write:
Now, let's create another variable y:
In this example, y equals 10. Now what if we updated the value of x:
Would y update along with x? Yes, y now equals 7. You can implement many simple functions similarly. For example:
is a simple fahrenheit to celsius convertor. The variable c updates every time f is updated. But what about recursive functions, like the fibonacci function?
fib(1)=1 fib(2)=1 fib(x)=fib(x-2)+fib(x-1)
Since variables cannot recurse, we use actual function notation, in this example to implement the fibonacci function.
Creating an array is simple:
It's just creating a variable with more than one value, separated by commas. You can perform regular operations on a whole array at a time:
Each item in the array is operated on separately, and then put back together. In this case, y would equal 2,4. Functions can also perform on arrays:
Since the 5th and 7th fibonacci numbers are 5 and 13 respectively, this example would return 5,13. Now what if our function accepted two arguments, such as a power function:
Function parameters, as well as array items, are separated by commas, so how would we work around this if we wanted to perform the above function on an array? "power(1,2,3,2)" could be interpreted many different ways, so we..
Use parenthesis to distinguish each parameter. Here we're squaring the array 1,2,3, so we get 1,4,9.
It's basically "set-by-name". As far as we know, functions are array transforms.