Skip to content

Commit 1c82d8a

Browse files
committed
more read me
1 parent 4e0d3ce commit 1c82d8a

File tree

1 file changed

+121
-1
lines changed

1 file changed

+121
-1
lines changed

README.md

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ So statements or programs in RoyalScript consist purely of functions and their a
3232

3333
##Types
3434

35-
RoyalScript is a dynamically typed language. This means that variables do not have to be declared with a specific type
35+
RoyalScript is a dynamically typed language. This means that variables do not have to be declared with a specific type, nor do functions need specified paramater or return types.
36+
37+
However, one of the goals of RoyalScript is to provide a stronger type system than JavaScript or other functional languages with the type and is functions, and the struct system RoyalScript has.
3638

3739
###Literal
3840

@@ -55,7 +57,125 @@ RoyalScript has 5 primitive types
5557

5658
Additionally, the null type exists to represent a *none* or *void* type present in many other languages.
5759

60+
Strings in RoyalScript are implemented with backtick barriers, \`, as opposed to quotes \" with most languages. This is primarily due to the optimized method of parsing RoyalScript, which will be explained in another section.
61+
62+
###Struct Type
63+
64+
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+
66+
##Arithmetic Functions
67+
68+
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.
69+
70+
###+(...)
71+
72+
The *+()* function adds an arbitrary number of arguments together. These can be numbers, or strings, which will be concatenated instead.
5873

74+
```
75+
>> +(4, 4)
76+
>> 8
77+
>> +(1, 3, 2)
78+
>> 6
79+
>> +(`hello`, ` `, `world!`)
80+
>> "hello world!"
81+
```
82+
83+
RoyalScript does not allow trailing commas in function calls:
84+
85+
```
86+
>> +(8, 7, )
87+
>> SyntaxError
88+
```
5989

90+
RoyalScript will coerce a number to a string type if they are both calld by the *+()* function.
6091

92+
```
93+
>> +(100, `k`)
94+
>> "100k"
95+
```
96+
97+
###-(...)
98+
99+
The *-()* function subtracts an arbitrary number of integers. It is associative to the left most argument, meaning:
100+
101+
```
102+
>> -(1, 1, 1)
103+
>> -1
104+
>> -(1, -1)
105+
>> 2
106+
```
107+
108+
###\*(...)
109+
110+
The *\*()* function multiplies an arbitrary number of integers. It is associative to the left most argument, meaning:
111+
112+
```
113+
>> *(1, -1, 1)
114+
>> -1
115+
>> *(10, 2)
116+
>> 20
117+
```
118+
###/(...)
119+
120+
The */()* function divides an arbitrary number of integers. It is left associative.
121+
122+
```
123+
>> /(3, 5)
124+
>> 0.6
125+
>> /(3, 10)
126+
>> 0.3
127+
>> /(3, 11)
128+
>> 0.2727272727272727
129+
```
130+
131+
###//(...)
132+
133+
The *//()* function uses floor divsion, by rounding the result to the next lowest integer, on an arbitrary amount of numbers. It is left associative
134+
135+
```
136+
>> //(1, 2)
137+
>> 0
138+
>> //(1, 10)
139+
>> 0
140+
>> //(55, 10)
141+
>> 5
142+
143+
```
144+
145+
###%(...)
146+
147+
The *%()* function takes the remainder of an arbitrary amount of numbers. It is also left associative.
148+
149+
```
150+
%(8, 3)
151+
2
152+
%(8, 1)
153+
0
154+
%(44, 8)
155+
4
156+
```
157+
###\*\*(...)
158+
159+
The *\*\*()* function, called the exponent function raises some left hand number to the power of the right hand number.
160+
161+
```
162+
**(2, 2)
163+
4
164+
```
165+
166+
###Nested Expressions
167+
168+
Arithmetic functions, like all functions in RoyalScript are nestable, you can call functions within functions to make for more powerful computability. See these examples:
169+
170+
```
171+
>> +(4, -(2, 3), *(8, 8))
172+
67
173+
>> -(3,
174+
.. +(3, 2)
175+
.. )
176+
2
177+
>> **(2, %(3, 3))
178+
1
179+
```
61180

181+
As demonstrated, any function, such as the *-()* can stretch across multiple lines if you so chose to do so.

0 commit comments

Comments
 (0)