|
4 | 4 |
|
5 | 5 | RoyalScript is a functional programming languag that aims to combine the utility of popular functional programming languages with the mutable data structures found in object oriented languages. The language is also quickly compiled to compressed JavaScript, so it can be run in the browser, without having to download anything on your computer. Lastly, RoyalScript is also inter-operable with javascript functions. You can call native javascript functions from RoyalScirpt as well!
|
6 | 6 |
|
| 7 | +RoyalScript is a both a compiled or interpreted language, this depends on the javascript environment that RoyalScript is run in. |
| 8 | + |
7 | 9 | ##Computational Functions
|
8 | 10 |
|
9 | 11 | The major difference between RoyalScript and other functional languags lik Scheme is that RoyalScript functions do not *always* evaluate to some resulting value. They do not always return a value. Some functions, such as the `for` function loops over some list of values. Another example is the
|
@@ -63,6 +65,17 @@ Strings in RoyalScript are implemented with backtick barriers, \`, as opposed to
|
63 | 65 |
|
64 | 66 | RoyalScript structs, grouped fields of data, create a new type for every different struct that is named and declared. These can be checked using the *type()* and *is()* functions, which are covered in more detail later.
|
65 | 67 |
|
| 68 | +##Comments |
| 69 | + |
| 70 | +Comments are the only feature of RoyalScript that are not functions or function calls. They are always denoted by semicolons, *;*, and can extend multiple lines or even be in the middle of code. |
| 71 | + |
| 72 | +``` |
| 73 | +>> +(1, 2) ;this is a comment; |
| 74 | +3 |
| 75 | +>> +(1, ;you can put them in the middle of code too; 2) |
| 76 | +3 |
| 77 | +``` |
| 78 | + |
66 | 79 | ##Arithmetic Functions
|
67 | 80 |
|
68 | 81 | RoyalScript has several arithmetic functions that are used to perform such operations on numbers. RoyalScript numbers are identical to JavaScript numbers which represent both integers and floats.
|
@@ -834,4 +847,43 @@ undefined
|
834 | 847 | 5
|
835 | 848 | ```
|
836 | 849 |
|
837 |
| -Double parameter procs can also be nested. |
| 850 | +Double parameter procs can also be nested. |
| 851 | + |
| 852 | +###!@(parameter, call\_exp) |
| 853 | + |
| 854 | +The *!@()* function produces a proc very similarly to the *@()* function except it does not return or evaluate to any value when the proc is called. It's specifically meant to modify mutable arguments like lists or structs, or be used in a loop. |
| 855 | + |
| 856 | +``` |
| 857 | +>> =(attach, !@(a, append(a, 3))) |
| 858 | +undefined |
| 859 | +>> =(test, make(4, 10)) |
| 860 | +undefined |
| 861 | +>> attach(test) |
| 862 | +undefined |
| 863 | +>> do(test) |
| 864 | +[4,4,4,4,4,4,4,4,4,4,3] |
| 865 | +>> attach(list(1, 2 ,3)) |
| 866 | +undefined ;does not return the list; |
| 867 | +``` |
| 868 | + |
| 869 | +Unlike the other procs, however, *!@()* can be extended with *do()*, as in the example below |
| 870 | + |
| 871 | +``` |
| 872 | +>> =(fnc, !@(a, |
| 873 | +.. do( |
| 874 | +.. append(a, 1), |
| 875 | +.. remove(a, 0), |
| 876 | +.. put(a, 3) |
| 877 | +.. ) |
| 878 | +.. ) |
| 879 | +.. ) |
| 880 | +undefined |
| 881 | +>> =(lst, list(1, 2)) |
| 882 | +undefined |
| 883 | +>> fnc(lst), do(lst) |
| 884 | +[3,2,1] |
| 885 | +``` |
| 886 | + |
| 887 | +#Loop Functions |
| 888 | + |
| 889 | +Unlike other functional programming languages, RoyalScript incorporates |
0 commit comments