Skip to content

Commit 1b48f4a

Browse files
committed
u
1 parent 8f2d327 commit 1b48f4a

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
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!
66

7+
RoyalScript is a both a compiled or interpreted language, this depends on the javascript environment that RoyalScript is run in.
8+
79
##Computational Functions
810

911
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
6365

6466
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.
6567

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+
6679
##Arithmetic Functions
6780

6881
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
834847
5
835848
```
836849

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

Comments
 (0)